SelectionChangedEventArgs::InvokeEventHandler Method (Delegate^, Object^)


Performs the proper type casting to call the type-safe SelectionChangedEventHandler delegate for the SelectionChanged event.

Namespace:   System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

virtual void InvokeEventHandler(
	Delegate^ genericHandler,
	Object^ genericTarget
) override


Type: System::Delegate^

The handler to invoke.

Type: System::Object^

The current object along the event's route.

The following example creates a ListBox and subscribes to the SelectionChanged event. It uses the SelectionChangedEventArgs to find the selected item in the ListBox.

<WrapPanel Width="500" Orientation="Horizontal" Name="rectanglesPanel">
    <Style TargetType="Rectangle">
      <Setter Property="Height" Value="20"/>
      <Setter Property="Width" Value="20"/>
      <Setter Property="Margin" Value="5"/>

<ListBox Name="myListBox" HorizontalAlignment="Left" SelectionMode="Extended" 
      Width="265" Height="55" Background="HoneyDew" SelectionChanged="myListBox_SelectionChanged"
      ItemsSource="{Binding Source={StaticResource Colors}}" IsSynchronizedWithCurrentItem="true">

No code example is currently available or this language may not be supported.

.NET Framework
Available since 3.0
Return to top