Posts

Showing posts with the label WPF

VisualStateManager.GoToState not working?

I’ve had issues with this on and off for a while and thought I should note my solution quickly.   Expression Blend will actually use ExtendedVisualStateManager, but the base class VisualStateManager has this solution as well. Basically, due to a bug that was supposed to be fixed, but for whatever reason still exists, the visual state sometimes won’t change using this method. The GoToState method takes a control, a state name string, and Boolean whether to use transition animations.   The solution is simple. There is another method called GotoElementState that takes a FrameworkElement, and the rest. Just use this instead and your problems go away.   1: // Avoid this. 2: VisualStateManager.GoToState(ctrl, stateName, true ); 3:   4: // Use this. 5: VisualStateManager.GoToElementState(ctrl, stateName, true );

Making a Screensaver On Windows

Image
Recently I was tasked with making a screensaver to run on Windows and it had to run on Windows XP, Windows Vista, and Windows 7. I decided to do it with WPF as that is my new favorite technology. So like all good developers I pulled up my browser and searched for somebody who’d done it already. After a little prodding, I found several articles with relevant code samples , a few MSDN pages and some other interesting stuff. I had my screensaver built shortly after.   Then came time to make the installer for the screensaver, a standard Windows installer is no big deal. This one just needed to add a couple of registry entries for the screensaver file to make it the default and copy the output file (an executable renamed with a . scr extension) to the appropriate folder. When I ran this everything worked beautifully, except now the dropdown that lets you choose your screensaver in the display properties only displays the filename of the output file, but on older Windows versions...