RoutedEventArgs.RoutedEvent 属性

定义

获取或设置与此 RoutedEventArgs 实例关联的 RoutedEvent

public:
 property System::Windows::RoutedEvent ^ RoutedEvent { System::Windows::RoutedEvent ^ get(); void set(System::Windows::RoutedEvent ^ value); };
public System.Windows.RoutedEvent RoutedEvent { get; set; }
member this.RoutedEvent : System.Windows.RoutedEvent with get, set
Public Property RoutedEvent As RoutedEvent

属性值

RoutedEvent

已调用的事件的标识符。

例外

在路由事件时试图更改 RoutedEvent 值。

示例

以下示例使用初始构造函数创建新的路由事件数据,然后将该属性设置为 RoutedEvent 后续操作。 必须在 RoutedEvent 引发路由事件之前进行设置。

protected virtual void OnSelectedColorChanged(Color oldColor, Color newColor)
{

    RoutedPropertyChangedEventArgs<Color> newEventArgs =
        new RoutedPropertyChangedEventArgs<Color>(oldColor, newColor);
    newEventArgs.RoutedEvent = ColorPicker.SelectedColorChangedEvent;
    RaiseEvent(newEventArgs);
}
Protected Overridable Sub OnSelectedColorChanged(ByVal oldColor As Color, ByVal newColor As Color)

    Dim newEventArgs As New RoutedPropertyChangedEventArgs(Of Color)(oldColor, newColor)
    newEventArgs.RoutedEvent = ColorPicker.SelectedColorChangedEvent
    MyBase.RaiseEvent(newEventArgs)
End Sub

注解

例如,如果通过处理程序) 获取参数,则无法针对已路由 (的值设置此值 RoutedEventArgs 。 尝试执行此操作将生成异常。 只能在尚未用于生成事件的调用的实例上设置它。

RoutedEvent 在任何时候都不能 null

适用于