This list box allows multiple user selections. : ListBox « Windows Presentation Foundation « C# / CSharp Tutorial






<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:src="clr-namespace:ListBoxEvent"  
    x:Class="ListBoxEvent.Pane1">


  <StackPanel>
    <DockPanel Margin="10, 10, 3, 3" >
      <ListBox SelectionMode="Multiple">
        <DockPanel>
          <Image Source="data\cat.png"/>
          <TextBlock>CAT</TextBlock>
        </DockPanel>
        <DockPanel>
          <Image Source="data\dog.png"/>
          <TextBlock>DOG</TextBlock>
        </DockPanel>
        <DockPanel>
          <Image Source="data\fish.png"/>
          <TextBlock>FISH</TextBlock>
        </DockPanel>
      </ListBox>
    </DockPanel>
  </StackPanel>

</Canvas>

//File:Window.xaml.cs
using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Data;
using System.Windows.Media;
using System.Collections.ObjectModel;

namespace ListBoxEvent
{

    public partial class Pane1 : Canvas
    {

        public Pane1() : base()
        {
            InitializeComponent();
        }
    }

}
WPF This List Box Allows Multiple User Selections








24.29.ListBox
24.29.1.ListBox and SelectionModeListBox and SelectionMode
24.29.2.ListBox Selected Index, Item, ValueListBox Selected Index, Item, Value
24.29.3.ListBox SelectionMode=SingleListBox SelectionMode=Single
24.29.4.Get Selected Item from ListBoxGet Selected Item from ListBox
24.29.5.Load the Items in a ListBox AsynchronouslyLoad the Items in a ListBox Asynchronously
24.29.6.ListBox selection changed eventListBox selection changed event
24.29.7.Handles ListBoxItem Selected events for the ListBoxItems in the inner ListBox.Handles ListBoxItem Selected events for the ListBoxItems in the inner ListBox.
24.29.8.Select All ListBox ItemsSelect All ListBox Items
24.29.9.Add selected file to ListBoxAdd selected file to ListBox
24.29.10.Fill up the ListBox with brush namesFill up the ListBox with brush names
24.29.11.Get selected item from ListBoxGet selected item from ListBox
24.29.12.This list box allows multiple user selections.This list box allows multiple user selections.
24.29.13.This list box allows items to be selected in groups by using the SHIFT key and mouse or the CTRL key and space key.This list box allows items to be selected in groups by using the SHIFT key and mouse or the CTRL key and space key.
24.29.14.Select All and unselect allSelect All and unselect all
24.29.15.Get selected item count from ListBoxGet selected item count from ListBox
24.29.16.View and Select Items Using a ListView and Select Items Using a List
24.29.17.Set text to TextBlock for selected list itemSet text to TextBlock for selected list item
24.29.18.Iterate through the selected items and remove each oneIterate through the selected items and remove each one
24.29.19.Ensure there is at least one item selectedEnsure there is at least one item selected