I am using MVVM pattern with Silverlight 4 to bind a collection of TODO items to a ListBox.
There is a property IsSelected
on each TODO
entity. This allow for multiple selections to be made in the UI that are bound back to the ViewModel. At the same time any changes made by the ViewModel get reflected in the View.
I am basically trying to do what was suggested in this answer.
Unfortunately in Silverlight (as opposed to WPF) I just cannot find a way to do this with the template since Bindings in a Style Setter are not supported in SL4.
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="IsSelected"
Value="{Binding Mode=TwoWay, Path=IsSelected}"/>
</Style>
</ListBox.ItemContainerStyle>
However unlike any other method - this seems to be the most reliable for two way binding of a selected items list.
How can I express this binding in codebehind or XAML?