The team blog of the Expression Blend and Design
As you know, Visual State Manager is a Silverlight 2 (and WPF Toolkit) platform feature that makes it easy to define a control’s visual states and to perform the transitions between states. In the case of a templated control (such as Button, CheckBox, etc) you need only fill in the states advertised by the control (using Blend’s States pane), and the control itself will take care of performing the transitions at the right time. But if you’re writing your own UserControl then you need to add your own states to the control and you also need to know how to handle events and call VisualStateManager.GoToState() to transition between your states. Attached to this blog post is a base class that I hope will get you off to a good start. Basically you can derive your own UserControl from this class and override some methods and hopefully that will have saved you some work.
First, download and extract the StatefulUserControlBase.cs source code file from the following location:
Once you’ve downloaded and extracted the source code file (StatefulUserControlBase.cs) you can try out the following steps.
public partial class CheckBoxUC : BlendHelpers.StatefulUserControlBase
CheckTwoStatesEnum _checkState = CheckTwoStatesEnum.Unchecked;
// Required to initialize variables
protected override void UserControl_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
_checkState = (CheckTwoStatesEnum)(1 - (int)_checkState);
protected override void UpdateState()
You now have a functioning two-state checkbox in the form of a UserControl. All you need to do next is to define the states as you would for the built-in CheckBox control. Naturally you won’t want to reproduce the built-in controls with your own UserControls, but now you know how to extend the base class you’ll be ready to do something more practical.
A completed sample is also provided.
I heard that VSM will be rolled into WPF.
Is Silverlight expected to ever have triggers for this sort of thing. Or is VSM superceding triggers?
I came across SilverlightShow this morning. It's an independent Silverlight community, and the goal of
In this issue: James Bacon, Chris Anderson, Jesse Liberty, Expression Blend and Design Blog, Laurent
As you know, Visual State Manager is a Silverlight 2 (and WPF Toolkit) platform feature that makes it