I recently used Expression Blend and I found that it has something called Visual State Manager, what is the difference between it and the regular event driven model, and which is better?
3 Answers
Events are for instances of "things" happening e.g.:
- Was I clicked?
- Did my timer fire?
- Is my data ready?
The Visual State Manager is used to manage multiple simultaneous states of a control.
- Am I pressed?
- Is the mouse over me?
- Am I checked?
Events are just callbacks to listening objects, while states are visual states, so basically there are used for completely different purposes. Events can trigger state changes, but that is the only overlap.

- 92,391
- 25
- 181
- 202
An object fires an event to indicate that something has occurred. The event carries an arbitrary payload (the event args) plus (by convention) the object which sent the event. Visual states define the different states of a control or user control. A visual state defines how a control looks, how it transitions to that look, and how it transitions away from that look. ("Transition" can involve anything from toggling the visibility all the way though a complicated animation.) Visual states are part of a control, but you can't directly subscribe to them as you can with events.
One model is not better than the other: they're simply different. Think of using events in your view model and model/service layers and visual states in your view layer.

- 6,355
- 3
- 38
- 48
Visual State manager is used for managing state (surprisingly). So for example your button can be in multiple sates:
- Mouse over
- Mouse down
- Disabled
- Enabled
You code doesn't really need to know about it, so all visual states of your application should be kept within XAML.
Also Visual state managers helps to reduce your code behind which is more error prone.
And as for events, in fact I tend to use commands more often now, I find them to be more useful than events on its own.

- 4,587
- 9
- 42
- 65