Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Selector.SelectionChanged Event

Occurs when the selection of a Selector changes.

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

public event SelectionChangedEventHandler SelectionChanged
/** @event */
public void add_SelectionChanged (SelectionChangedEventHandler value)

/** @event */
public void remove_SelectionChanged (SelectionChangedEventHandler value)

In JScript, you can handle the events defined by a class, but you cannot define your own.
<object SelectionChanged="SelectionChangedEventHandler" .../>

Identifier Field

SelectionChangedEvent

Routing Strategy

Bubbling

Delegate

SelectionChangedEventHandler

This event occurs whenever there is a change to a selection. A selection can be changed not only by user interaction but also by binding as well as other set values.

The following example shows how to attach the SelectionChanged event to a list box control.

<TextBox Name="tb" Width="140" Height="30"></TextBox>
<ListBox Name="lb" Width="100" Height="55" SelectionChanged="PrintText" SelectionMode="Single">
  <ListBoxItem>Item 1</ListBoxItem>
  <ListBoxItem>Item 2</ListBoxItem>
  <ListBoxItem>Item 3</ListBoxItem>
  <ListBoxItem>Item 4</ListBoxItem>
  <ListBoxItem>Item 5</ListBoxItem>
  <ListBoxItem>Item 6</ListBoxItem>
  <ListBoxItem>Item 7</ListBoxItem>
  <ListBoxItem>Item 8</ListBoxItem>
  <ListBoxItem>Item 9</ListBoxItem>
  <ListBoxItem>Item 10</ListBoxItem>
</ListBox>

The following example shows how to handle the SelectionChanged event.

void PrintText(object sender, SelectionChangedEventArgs args)
{
    ListBoxItem lbi = ((sender as ListBox).SelectedItem as ListBoxItem);
    tb.Text = "   You selected " + lbi.Content.ToString() + ".";
}

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

Community Additions

Show:
© 2014 Microsoft