This documentation is archived and is not being maintained.

ListBox.SelectionMode Property

Gets or sets the selection behavior for a ListBox.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public SelectionMode SelectionMode { get; set; }
/** @property */
public SelectionMode get_SelectionMode ()

/** @property */
public void set_SelectionMode (SelectionMode value)

public function get SelectionMode () : SelectionMode

public function set SelectionMode (value : SelectionMode)

<object SelectionMode="SelectionMode" .../>

Property Value

The default selection mode is Single selection. See SelectionMode for a list of possible modes.

This example shows how to set the selection modes for ListBox. The SelectionMode property indicates how many ListBoxItem elements a user can select at one time. You can set this property to Single (the default value), Multiple, or Extended. The following example shows how to create a ListBox where users can select more than one item (Multiple selections).

<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>

For the complete sample, see List Box Sample.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Show: