Blend 2 SP1 + WPF Toolkit = Visual State Manager for WPF
The Blend 2 Service Pack 1 contains a secret ingredient that can be activated by installing the WPF Toolkit and then setting a Registry value. In a nutshell, this ingredient is Visual State Manager support for Windows Presentation Foundation projects. As you know, Visual State Manager is built into Silverlight 2 but the WPF Toolkit gives you an early peek into the future of VSM-for-WPF.
The WPF Toolkit is a collection of WPF features and components that are being made available outside of the normal .NET Framework ship cycle. The WPF Toolkit not only allows users to get new functionality more quickly, but allows an efficient means for giving feedback to the product team.
Once you have the Blend 2 Service Pack 1 installed, here are the steps you need to follow to get to the VSM-for-WPF goodness:
- Install the WPF Toolkit from https://www.codeplex.com/wpf/Release/ProjectReleases.aspx?ReleaseId=15598
- Create the following registry value and make it non-zero. The value should be of type DWORD. Or run the appropriate .REG file attached to this post (or by clicking here).
- 32 bit OS : HKLM/Software/Microsoft/Expression/Blend/EnableVSM
- 64 bit OS : HKLM/Software/Wow6432Node / Microsoft/Expression/Blend/EnableVSM
- 32 bit OS : HKLM/Software/Microsoft/Expression/Blend/EnableVSM
- If Blend was running during the previous step then restart it.
- Create a new WPF project.
- Add %Program Files%\WPF\WPF Toolkit\...\WPFToolkit.dll to the References folder (Right-click the References node in Project, then click Add Reference…).
- Close and reopen Window1.xaml. The States pane will now appear for the project.
Here are some VSM resources to get you going: https://blogs.msdn.com/expression/archive/2008/07/11/more-articles-on-visual-state-manager.aspx
Even though the built-in WPF controls (such as Button and CheckBox) weren’t designed with VSM in mind, the toolkit works some event interception magic that means your Visual States are applied provided they’re given the standard names such as Normal, MouseOver, Pressed, Disabled, Unchecked, Checked and so on. You can also use VSM-for-WPF to add interactivity to new custom controls you author yourself, although be aware that Blend will not read any default VisualState information out of the default template. And of course you can also add VSM interactivity to UserControls.
We hope you have fun!
-Steve
Comments
Anonymous
October 30, 2008
PingBack from http://mstechnews.info/2008/10/blend-2-sp1-wpf-toolkit-visual-state-manager-for-wpf/Anonymous
October 30, 2008
I tried doing this on 64 bit vista, the vsm doesn't appear when I reopen window1.xaml...what could I be missing? I updated the registry for 64 restarted blend and imported the dll...do I need a namespace in the xaml file?Anonymous
October 30, 2008
The Blend 2 Service Pack 1 contains a secret ingredient that can be activated by installing the WPF ToolkitAnonymous
October 30, 2008
The Blend 2 Service Pack 1 contains a secret ingredient that can be activated by installing the WPF ToolkitAnonymous
October 30, 2008
I got the State panel to show up in Blend 2 SP1 but it does not appear to be interactive; that is, I cannot add a state. Do I have to add it in code behind? If so, what is the advantage of having the State panel? I am not criticizing, just trying to understand. :)Anonymous
October 30, 2008
As mentioned above, this Blend support for VSM in WPF is similar to that for Silverlight. So you can only add states to a UserControl or a control template. Thanks.Anonymous
October 30, 2008
To clarify the above, you cannot add States to project items of type Window, Page or ResourceDictionary. ThanksAnonymous
October 30, 2008
Got it! Wow, that is Awesome! I was confused because an SL project allows you to create States right on the main Workspace. Putting it into a UserControl is fine though, just a little extra work. Thanks for the help.Anonymous
November 04, 2008
Now that the Visual State Manager (VSM) is part of the WPFToolKit, I thought I’d show a basic exampleAnonymous
November 05, 2008
I’ve already blog’d about the WPF Toolkit & the WPF Ribbon Preview .  One of the things thatAnonymous
November 05, 2008
I’ve already blog’d about the WPF Toolkit & the WPF Ribbon Preview .  One of the things thatAnonymous
November 13, 2008
Some great WPF resources/previews were made available after the PDC keynote: · WPF Toolkit includingAnonymous
November 13, 2008
Some great WPF resources/previews were made available after the PDC keynote: · WPF Toolkit includingAnonymous
November 16, 2008
Can you change the state of a user control from an event on the parent window? How?Anonymous
November 19, 2008
Der Visual State Manager für Silverlight in Expression Blend 2 (SP 1) ist zweifellos eines der LieblingsfeaturesAnonymous
November 24, 2008
Blend 2 SP1 + WPF Toolkit = Visual State Manager for WPF En une équation comme le rappelle l’équipe produitAnonymous
November 30, 2008
States disappear from the State view in the design view. They are still in the XAML and all work fine, but they just do not show up in the state viewer anymore and therefore I am unable to add or change states. Anybody experiencing the same problem?Anonymous
December 18, 2008
I love the VSM for WPF, it is a great feature! I am curious, though: I can't seem to be able to use a local resource in my States. whenever I use a local resource, say to change a Border color in MousePressed, it alters the entire template. If I use a normal color, all is well. Also, is there a way to copy a state? For instance, MouseOver has a a particular design which is different than Normal: but when I want a different design for MousePressed, I want the MouseOver state to be the starting point, not Normal. In other words, I have to replicate the MouseOver state first, and then make my changes, in order to achieve the effect I want from MousePressed. I hope I expressed that OK. Thanks for all the great work, I look forward to your future releases!Anonymous
May 06, 2009
Hello Steve, Hate to beat a dead horse, but this is not working for me. I have a full license copy of Expression Blend with SP1 and the latest WPFTookKit. Even though I open a UserControl the States does not show up. Not even when I modify the template for that user control either. Any ideas?Anonymous
May 06, 2009
Hi Rashad, if you install the October 2008 version of the WPF toolkit, set the reg key, restart Blend, create a new WPF project, reference the toolkit dll, close and reopen Window 1, then you'll get the States pane. Hope that helps. I would urge you to look at the Blend 3 preview though: http://expression.microsoft.com/en-us/cc507094.aspx#blend3preview -Steve