Esporta (0) Stampa
Espandi tutto

Evento Selector.SelectionChanged

Occurs when the selection of a Selector changes.

Spazio dei nomi: System.Windows.Controls.Primitives
Assembly: PresentationFramework (in presentationframework.dll)
Spazio dei nomi XML:  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 è possibile gestire gli eventi definiti da una classe, ma non è possibile definirne di personalizzati.
<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() + ".";
}

Microsoft .NET Framework 3.0 è supportato in Windows Vista, Microsoft Windows XP SP2 e Windows Server 2003 SP1.

.NET Framework

Supportato in:

Aggiunte alla community

AGGIUNGI
Mostra:
© 2014 Microsoft