RaiseEvent 方法
UIElement.RaiseEvent 方法
Raises a specific routed event. The RoutedEvent to be raised is identified within the RoutedEventArgs instance that is provided (as the RoutedEvent property of that event data).

命名空间: System.Windows
程序集: PresentationCore(在 presentationcore.dll 中)

Visual Basic(声明)
Public Sub RaiseEvent ( _
    e As RoutedEventArgs _
)
Visual Basic (用法)
Dim instance As UIElement
Dim e As RoutedEventArgs

instance.RaiseEvent(e)
C#
public void RaiseEvent (
    RoutedEventArgs e
)
C++
public:
virtual void RaiseEvent (
    RoutedEventArgs^ e
) sealed
J#
public final void RaiseEvent (
    RoutedEventArgs e
)
JScript
public final function RaiseEvent (
    e : RoutedEventArgs
)
XAML
不能在 XAML 中使用方法。

参数

e

A RoutedEventArgs that contains the event data and also identifies the event to raise.

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 is not just the state properties for the event; it also identifies which routed event to raise. This event-raising pattern and the routed event data both differ from common language runtime (CLR) events and data classes, which typically just contain properties that are related to the event.

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.

C#
 void RaiseTapEvent()
 {
        RoutedEventArgs newEventArgs = new RoutedEventArgs(MyButtonSimple.TapEvent);
        RaiseEvent(newEventArgs);
}

Windows Vista、Microsoft Windows XP SP2 和 Windows Server 2003 SP1 支持 Microsoft .NET Framework 3.0。

.NET Framework

受以下版本支持:3.0
社区内容   什么是社区内容?
添加新内容 RSS  批注
Processing
Page view tracker