RoutedEventArgs.RoutedEvent 屬性

定義

取得或設定與這個 RoutedEventArgs 執行個體相關聯的 RoutedEventGets or sets the RoutedEvent associated with this RoutedEventArgs instance.

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

屬性值

已叫用之事件的識別項。The identifier for the event that has been invoked.

例外狀況

嘗試在路由事件時變更 RoutedEvent 值。Attempted to change the RoutedEvent value while the event is being routed.

範例

下列範例會使用初始的函式來建立新的路由事件資料,然後將 RoutedEvent 屬性設定為後續作業。The following example creates new routed event data with an initial constructor and then sets the RoutedEvent property as a subsequent operation. 您必須先設定 RoutedEvent,才會引發路由事件。You must have RoutedEvent set prior to raising the routed event.

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 上設定這個值(例如,如果您透過處理常式取得引數)。You cannot set this value on a RoutedEventArgs that has already been routed (for instance, if you obtained the arguments through a handler). 嘗試這麼做將會產生例外狀況。Attempting to do so will generate an exception. 您只能在尚未用來產生事件調用的實例上設定它。You can only set it on an instance that has not yet been used to generate an invocation of the event.

RoutedEvent 的值不能在任何時間 nullThe value of RoutedEvent cannot be null at any time.

適用於