Selector.SelectionChanged 이벤트

정의

Selector의 선택 영역이 변경될 때 발생합니다.

public:
 event System::Windows::Controls::SelectionChangedEventHandler ^ SelectionChanged;
public event System.Windows.Controls.SelectionChangedEventHandler SelectionChanged;
member this.SelectionChanged : System.Windows.Controls.SelectionChangedEventHandler 
Public Custom Event SelectionChanged As SelectionChangedEventHandler 

이벤트 유형

예제

다음 예제에서는 목록 상자 컨트롤에 SelectionChanged 이벤트를 연결 하는 방법을 보여 있습니다.

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

다음 예제에서는 처리 하는 방법을 보여 줍니다는 SelectionChanged 이벤트입니다.

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

    Dim lbsender As ListBox
    Dim li As ListBoxItem

    lbsender = CType(sender, ListBox)
    li = CType(lbsender.SelectedItem, ListBoxItem)
    tb.Text = "   You selected " & li.Content.ToString & "."
End Sub

설명

이 이벤트는 선택 영역이 변경 될 때마다 발생 합니다. 선택 영역은 사용자 상호 작용뿐만 아니라 다른 집합 값뿐만 아니라 바인딩을 통해 변경할 수 있습니다.

라우팅 이벤트 정보

식별자 필드 SelectionChangedEvent
라우팅 전략 버블링
대리자 SelectionChangedEventHandler

적용 대상