Silverlight 5 – ListBox with Checkboxes
This is how you make a Listbox show checkboxes for selection in Silverlight 5.
<ListBox x:Name="TestList" SelectionMode="Multiple">
<ListBox.ItemTemplate>
<DataTemplate>
<CheckBox
IsChecked="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem}, Path=IsSelected}"
Content="{Binding}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
And here’s a bit of sample code to set it up
public MainPage()
{
InitializeComponent();
SetupListBox();
}
public void SetupListBox()
{
TestList.ItemsSource = new String[]
{
"Andrew", "Frasier", "Mellon", "Dale"
};
}
About this entry
You’re currently reading “ Silverlight 5 – ListBox with Checkboxes ,” an entry on Chui's Counterpoint
- Published:
- 1.9.12 / 10am
- Category:
- Silverlight
Comments are closed
Comments are currently closed on this entry.