Freigeben über


Hey WPF Button, where are your States?

As you may know, when you create a template for a Silverlight control, the States pane in Blend populates with States ready for you to select-and-design. This is because Silverlight controls are designed to work with States, and each Silverlight control advertises the States it works with. But WPF shipped before States did and consequently WPF controls know nothing about States. It’s actually the magic in the WPF Toolkit that makes WPF controls work with States. When Blend 3 ships, its installer will also install the WPF Toolkit for you, but until then you can install it yourself from here: https://www.codeplex.com/wpf/Release/ProjectReleases.aspx.
This means that when you create a new template for a WPF control, the States pane is empty initially. But it only takes a few moments to add the correctly-named States and from there you’re on par with the Silverlight experience and you’re ready to select-and-design as usual.

So, here’s a list of the WPF controls that work with States along with the state groups and states you’ll need to add.

Button, GridViewColumnHeader, RepeatButton

CommonStates:

                Normal, MouseOver, Pressed, Disabled

FocusStates:

                Unfocused, Focused

 

CheckBox, RadioButton

CommonStates:

                Normal, MouseOver, Pressed, Disabled

CheckStates:

                Unchecked, Checked, Indeterminate

FocusStates:

                Unfocused, Focused

 

ListBoxItem

CommonStates:

                Normal, MouseOver

SelectionStates:

                Unselected, Selected

FocusStates:

                Unfocused, Focused

 

ProgressBar

CommonStates:

                Determinate, Indeterminate

FocusStates:

                Unfocused, Focused

 

TextBox, RichTextBox

CommonStates:

                Normal, MouseOver, Disabled, ReadOnly

FocusStates:

                Unfocused, Focused