Search code examples
silverlightsilverlight-4.0datatriggervsm

What is the replacement for DataTrigger in Silverlight


This is my scenario.

I have 2 Properties. Type and State.

Type is an Enum with 3 values eg, ball, car, arrow. State is an int which would accept 3 state values eg., -1, 0, 1. Also, I have 9 images for each state values.

Like, if I select type as ball and value as -1, I want to display a Red color ball. If I select type as arrow and value as 1, I want to display a up arrow. etc.,

I'm able to do this in WPF. I created 3 DataTemplates with an empty Image. Then, I use DataTrigger to check and update the particular image for the selected StateValue.

But, in silverlight how can I do this. I know, I have to do it in VSM. But, I would like to know some more details regarding this (or) any alternatives available.


Solution

  • I'd just use a converter that takes your object with 2 properties and returns an image. Code like that in pure XAML is painful and really belongs in C#.