views:

39

answers:

2

The MSDN documentation for Silverlight now states in several places:

The entire Triggers syntax is a discouraged technique in Silverlight 4. [1, 2]

Expression Blend seems to happily support and encourage their use, though, and there are plenty of blog posts extolling the use of Triggers and Actions without any caveats.

What is the recommended replacement for triggers? Should I stick to code-behind event handlers?

+3  A: 

In Silverlight they introduced the VisualStateManager which is seen as a cleaner way of achieving what Triggers are normally used for. It was well received and (I think) has since been added to WPF.

Tim Heuer's blog has a fairly good introduction to using the VSM:

http://timheuer.com/blog/archive/2008/06/04/silverlight-introduces-visual-state-manager-vsm.aspx

Simon Steele
You're right, it was added to WPF in .NET 4.
Dan Puzey
+4  A: 

Your get mixed up between two different Triggers. The MSDN documentation you point to are Silverlight SDK System.Windows triggers that apart from supporting the Loaded event can do nothing else.

The plethora of Triggers and Actions you are seeing in blog posts refer the Blend SDK which have a much wider scope and are very useful.

AnthonyWJones
You're absolutely right. I confused `System.Windows.TriggerAction` with `System.Windows.Interactivity.TriggerAction<T>`.
kpozin