Skip to main content
UIElementRaiseEvent Method
 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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

Namespace:   System.Windows
Assembly:  PresentationCore (in PresentationCore.dll)

public void RaiseEvent(
	RoutedEventArgs e
)
public:
virtual void RaiseEvent(
	RoutedEventArgs^ e
) sealed
abstract RaiseEvent : 
        e:RoutedEventArgs -> unit
override RaiseEvent : 
        e:RoutedEventArgs -> unit
Public Sub RaiseEvent (
	e As RoutedEventArgs
)

Parameters

e
Type:

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.

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
.NET Framework
Available since 3.0
Return to top