UIElement.RaiseEvent(RoutedEventArgs) UIElement.RaiseEvent(RoutedEventArgs) UIElement.RaiseEvent(RoutedEventArgs) UIElement.RaiseEvent(RoutedEventArgs) Method

定义

引发特定路由事件。Raises a specific routed event. 在提供的 RoutedEventArgs 实例内标识将引发的 RoutedEvent(作为该事件数据的 RoutedEvent 属性)。The RoutedEvent to be raised is identified within the RoutedEventArgs instance that is provided (as the RoutedEvent property of that event data).

public:
 virtual void RaiseEvent(System::Windows::RoutedEventArgs ^ e);
public void RaiseEvent (System.Windows.RoutedEventArgs e);
abstract member RaiseEvent : System.Windows.RoutedEventArgs -> unit
override this.RaiseEvent : System.Windows.RoutedEventArgs -> unit
Public Sub RaiseEvent (e As RoutedEventArgs)

参数

e
RoutedEventArgs RoutedEventArgs RoutedEventArgs RoutedEventArgs

一个 RoutedEventArgs,其中包含事件数据并标识要引发的事件。A RoutedEventArgs that contains the event data and also identifies the event to raise.

实现

示例

下面的示例创建事件数据、将事件标识符追加到数据, 然后使用事件数据实例引发自定义路由事件。The following example creates event data, appends the event identifier to the data, and then uses the event data instance to raise a custom routed event.

void RaiseTapEvent()
{
        RoutedEventArgs newEventArgs = new RoutedEventArgs(MyButtonSimple.TapEvent);
        RaiseEvent(newEventArgs);
}
Private Sub RaiseTapEvent()
    Dim newEventArgs As New RoutedEventArgs(MyButtonSimple.TapEvent)
    MyBase.RaiseEvent(newEventArgs)
End Sub

注解

参数被类型化为所有路由事件数据的公共基类型; 但是, 应将事件数据指定为可用于引发事件的最特定事件数据类型, 因为RoutedEventArgs派生类包含e在引发特定事件时用于特定事件的实际特定数据属性。The e parameter is typed as the common base type for all routed event data; however, the event data should be given as the most specific event data type that is available for the event being raised, because RoutedEventArgs derived classes contain the actual specific data properties that are intended for the specific event when it is raised.

RoutedEventArgs不只是事件的状态属性;它还标识要引发的路由事件。RoutedEventArgs is not just the state properties for the event; it also identifies which routed event to raise. 此事件引发模式和路由事件数据都不同于公共语言运行时 (CLR)common language runtime (CLR)事件和数据类, 通常只包含与事件相关的属性。This event-raising pattern and the routed event data both differ from 公共语言运行时 (CLR)common language runtime (CLR) events and data classes, which typically just contain properties that are related to the event.

适用于