R – Silverlight MVVM ListBoxItem IsSelected

listboxmvvmsilverlight

I have a collection of ViewModels bound to a ListBox. I am trying to bind the IsSelected properties of each together. In WPF it works by setting the style:

<Style TargetType="{x:Type ListBoxItem}">
    <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />
</Style>

This does not work in Silverlight. How can I accomplish this?

Best Answer

In Silverlight, you are not able to create "global" styles, that is, styles that modify all controls of a certain type. Your style needs a key, and your control needs to reference it.

Also, TargetType simply needs the control type name. Silverlight does not support the x:Type extension.

ib.