SelectionChangedEventArgs 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
이벤트에 대한 SelectionChanged 데이터를 제공합니다.
public ref class SelectionChangedEventArgs : System::Windows::RoutedEventArgs
public class SelectionChangedEventArgs : System.Windows.RoutedEventArgs
type SelectionChangedEventArgs = class
inherit RoutedEventArgs
Public Class SelectionChangedEventArgs
Inherits RoutedEventArgs
- 상속
예제
다음 예제에서는 이벤트를 만들고 ListBox 구독합니다 SelectionChanged . 를 SelectionChangedEventArgs 사용하여 .에서 선택한 항목을 찾습니다 ListBox.
<WrapPanel Width="500" Orientation="Horizontal" Name="rectanglesPanel">
<WrapPanel.Resources>
<Style TargetType="Rectangle">
<Setter Property="Height" Value="20"/>
<Setter Property="Width" Value="20"/>
<Setter Property="Margin" Value="5"/>
</Style>
</WrapPanel.Resources>
</WrapPanel>
<ListBox Name="myListBox" HorizontalAlignment="Left" SelectionMode="Extended"
Width="265" Height="55" Background="HoneyDew" SelectionChanged="myListBox_SelectionChanged"
ItemsSource="{Binding Source={StaticResource Colors}}" IsSynchronizedWithCurrentItem="true">
</ListBox>
void myListBox_SelectionChanged(object sender, SelectionChangedEventArgs args)
{
BrushConverter converter = new BrushConverter();
// Show Rectangles that are the selected colors.
foreach (string color in args.AddedItems)
{
if (GetRectangle(color) == null)
{
Rectangle aRect = new Rectangle();
aRect.Fill = (Brush) converter.ConvertFrom(color);
aRect.Tag = color;
rectanglesPanel.Children.Add(aRect);
}
}
// Remove the Rectangles that are the unselected colors.
foreach (string color in args.RemovedItems)
{
FrameworkElement removedItem = GetRectangle(color);
if (removedItem != null)
{
rectanglesPanel.Children.Remove(removedItem);
}
}
}
FrameworkElement GetRectangle(string color)
{
foreach (FrameworkElement rect in rectanglesPanel.Children)
{
if (rect.Tag.ToString() == color)
return rect;
}
return null;
}
Private Sub myListBox_SelectionChanged(ByVal sender As Object, ByVal args As SelectionChangedEventArgs)
Dim converter As BrushConverter = New BrushConverter()
Dim color As String
' Show Rectangles that are the selected colors.
For Each color In args.AddedItems
If GetRectangle(color) Is Nothing Then
Dim aRect As Rectangle = New Rectangle()
aRect.Fill = CType(converter.ConvertFrom(color), Brush)
aRect.Tag = color
rectanglesPanel.Children.Add(aRect)
End If
Next
' Remove the Rectangles that are the unselected colors.
For Each color In args.RemovedItems
Dim removedItem As FrameworkElement = GetRectangle(color)
If Not removedItem Is Nothing Then
rectanglesPanel.Children.Remove(removedItem)
End If
Next
End Sub
Private Function GetRectangle(ByVal color As String) As FrameworkElement
Dim rect As FrameworkElement
For Each rect In rectanglesPanel.Children
If rect.Tag.ToString() = color Then
Return rect
End If
Next
Return Nothing
End Function
생성자
| Name | Description |
|---|---|
| SelectionChangedEventArgs(RoutedEvent, IList, IList) |
SelectionChangedEventArgs 클래스의 새 인스턴스를 초기화합니다. |
속성
| Name | Description |
|---|---|
| AddedItems |
선택한 항목이 포함된 목록을 가져옵니다. |
| Handled |
경로를 이동할 때 라우트된 이벤트에 대한 이벤트 처리의 현재 상태를 나타내는 값을 가져오거나 설정합니다. (다음에서 상속됨 RoutedEventArgs) |
| OriginalSource |
부모 클래스에서 조정 Source 하기 전에 순수 적중 테스트에 의해 결정된 원래 보고 원본을 가져옵니다. (다음에서 상속됨 RoutedEventArgs) |
| RemovedItems |
선택되지 않은 항목이 포함된 목록을 가져옵니다. |
| RoutedEvent |
이 RoutedEvent 인스턴스와 연결된 값을 RoutedEventArgs 가져오거나 설정합니다. (다음에서 상속됨 RoutedEventArgs) |
| Source |
이벤트를 발생시킨 개체에 대한 참조를 가져오거나 설정합니다. (다음에서 상속됨 RoutedEventArgs) |
메서드
| Name | Description |
|---|---|
| Equals(Object) |
지정된 개체가 현재 개체와 같은지 여부를 확인합니다. (다음에서 상속됨 Object) |
| GetHashCode() |
기본 해시 함수로 사용됩니다. (다음에서 상속됨 Object) |
| GetType() |
현재 인스턴스의 Type 가져옵니다. (다음에서 상속됨 Object) |
| InvokeEventHandler(Delegate, Object) |
이벤트에 대한 형식 안전 SelectionChangedEventHandler 대리자를 호출하는 적절한 형식 캐스팅을 수행합니다 SelectionChanged . |
| MemberwiseClone() |
현재 Object단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
| OnSetSource(Object) |
파생 클래스에서 재정의되는 경우 인스턴스 속성의 Source 값이 변경될 때마다 알림 콜백 진입점을 제공합니다. (다음에서 상속됨 RoutedEventArgs) |
| ToString() |
현재 개체를 나타내는 문자열을 반환합니다. (다음에서 상속됨 Object) |