Thursday, March 18, 2010

Multiple selection in Silverlight ListBox

Hi All,

We can easily make any list box as enable to select multiple items in silver light.We just need to set the "SelectionMode" property of that list box below is the example for doing so.

ListBox Margin="5" x:Name="lbItems"
ItemsSource="{Binding Item, ElementName=MainPageView}"
StackPanel Orientation="Horizontal" Margin="4">
TextBlock FontWeight="Bold" FontSize="12"
Foreground="#ff005588" Text="{Binding Text}">

There are 3 options for the SelectionMode property that are:

Single -> Used to select only one item.

Multiple -> Used to select multiple items using Ctrl or Shift key.

Extended -> Used to select multiple items but here using Shift key you can select items range by just pressing one item, holding Shift and pressing another one.

Hope this is going to help you out... Enjoy!!!!!!

Anil Kumar Pandey
Micorsoft MVP (C#)
Navi Mumbai,