Hi
I am having an issue binding the IsSelected property of a RadListboxItem. Specifically I am attempting to follow the pattern provided in this blog post Accessing WPF ListBox SelectedItems using MVVM (markwithall.com)
The key part toward the bottom of the post is this which binds the IsSelected property of a ListBoxItem. I have tested it and it works just fine.
<ListBox ItemsSource="{Binding Items}" SelectionMode="Extended">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="IsSelected" Value="{Binding IsSelected}" />
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
However when I try to use a RadListbox and setup the ItemContainerStyle like this
<telerik:RadListBox.ItemContainerStyle>
<Style TargetType="telerik:RadListBoxItem" BasedOn="{StaticResource RadListBoxItemStyle}">
<Setter Property="IsSelected" Value="{Binding IsSelected}" />
</Style>
</telerik:RadListBox.ItemContainerStyle>
Hi Stenly, thankyou for the example. It shows the binding from source works, I wanted to see two way binding work. I realised that I had not specifically set Mode=Twoway, I did not think I had to since it was working fine in the Listbox example. I have now updated the binding to
<Style TargetType="telerik:RadListBoxItem" BasedOn="{StaticResource RadListBoxItemStyle}"> <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/> </Style>