« WCF 4.0 –Part 1 | Main | ASP.NET MVC – Understanding the Model-View-Controller (MVC) pattern »

Visual State Manager feature for a WPF project – Expression Blend Based Approach

The Visual State Manager feature of Expression Blend 3 works right out of the box for Silverlight development projects. For WPF projects, the feature is not supported out of the box.  A few simple steps listed below can help you get there.

Visual State Manager was introduced in Expression 2.0 version.  WPF platform has been out much before that so the catching up was done by releasing the WPF Tool kit  The WPF Toolkit is a collection of WPF features and components that are 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.
For Expression Bled 2, the tool kit had to be separately downloaded and configured.  With Expression Blend 3, the WPFToolkit is a part of the install process.
Here is what you need to do get the Visual States Manager to work ( after WPF Toolkit is installed) inside a WPF project.

  1. Create the following registry value and make it non-zero. The value should be of type DWORD. 
    • 32 bit OS : HKLM/Software/Microsoft/Expression/Blend/EnableVSM
       
    • 64 bit OS : HKLM/Software/Wow6432Node/Microsoft/Expression/Blend/EnableVSM
       
  2. If Blend was running during the previous step then restart it.
     
  3. Create a new WPF project.
     
  4. Add %Program Files%\WPF\WPF Toolkit\...\WPFToolkit.dll to the References folder (Right-click the References node in Project, then click Add Reference…).
     
  5. Close and reopen Window1.xaml. The States pane will now appear for the project.

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. An excellent resource for Visual State Manager Design and Authoring can be found here on the Expression Blend team blog site.

TrackBack

TrackBack URL for this entry:
http://www.infosysblogs.com/apps/mt-tb.cgi/2000

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Please key in the two words you see in the box to validate your identity as an authentic user and reduce spam.

Subscribe to this blog's feed

Follow us on

Blogger Profiles

Infosys on Twitter