Recommended

Skip Navigation LinksHome / Tips / View Tip

Enable multiple selection in Silverlight 3 ListBox

+ Add to SilverlightShow Favorites
1 comments   /   posted by Nikolay Raychev on Apr 02, 2009
(4 votes)
Categories: General
In Silverlight 3 you can make multiple selections in a ListBox. You just need to set the SelectionMode parameter:

<ListBox Margin="5" x:Name="lbTasks"   
    ItemsSource="{Binding Tasks, ElementName=MainPageView}"   
    SelectionMode="Multiple">  
    <ListBox.ItemTemplate> 
        <DataTemplate> 
            <StackPanel Orientation="Horizontal" Margin="2">  
                <TextBlock FontWeight="Bold" FontSize="13"   
                    Foreground="#ff006882" Text="{Binding Text}">  
                </TextBlock> 
            </StackPanel> 
        </DataTemplate> 
    </ListBox.ItemTemplate> 
</ListBox> 

You have 3 options for the SelectionMode:
  • Single - you can select only one item.
  • Multiple - you can select multiple items by selecting one item, holding Ctrl or Shift key and pressing another item.
  • Extended - you can again select multiple items but the Shift key acts differently. With the help of the Shift key you can select items range by just pressing one item, holding Shift and pressing another one.
Share


Comments

Comments RSS RSS
  • RE: Enable multiple selection in Silverlight ListBox  

    posted by Ola Karlsson on Jun 29, 2009 06:01
    Hi there,

    Any chance you could rename this to "Enable multiple selection in Silverlight 3 ListBox".

    I was searching for Silverlight listbox info anf got this from Google. As using Silverlight 3, at this point in time isn't an option from me, this was less than useful...

    Thanks

Add Comment

 
 

   
  
  
   
Please add 7 and 6 and type the answer here:

Help us make SilverlightShow even better and win a free t-shirt. Whether you'd like to suggest a change in the structure, content organization, section layout or any other aspect of SilverlightShow appearance - we'd love to hear from you! Need a material (article, tutorial, or other) on a specific topic? Let us know and SilverlightShow content authors will work to have that prepared for you. (hide this)