Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 4
System.Windows
 RoutedEvent Property
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2010/.NET Framework 4

Other versions are also available for the following:
.NET Framework Class Library
RoutedEventArgs..::.RoutedEvent Property

Gets or sets the RoutedEvent associated with this RoutedEventArgs instance.

Namespace:  System.Windows
Assembly:  PresentationCore (in PresentationCore.dll)
Visual Basic
Public Property RoutedEvent As RoutedEvent
    Get
    Set
C#
public RoutedEvent RoutedEvent { get; set; }
Visual C++
public:
property RoutedEvent^ RoutedEvent {
    RoutedEvent^ get ();
    void set (RoutedEvent^ value);
}
F#
member RoutedEvent : RoutedEvent with get, set

Property Value

Type: System.Windows..::.RoutedEvent
The identifier for the event that has been invoked.
ExceptionCondition
InvalidOperationException

Attempted to change the RoutedEvent value while the event is being routed.

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.

The value of RoutedEvent cannot be nullNothingnullptra null reference (Nothing in Visual Basic) at any time.

The following example creates new routed event data with an initial constructor and then sets the RoutedEvent property as a subsequent operation. You must have RoutedEvent set prior to raising the routed event.

Visual Basic
        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
C#
protected virtual void OnSelectedColorChanged(Color oldColor, Color newColor)
{

    RoutedPropertyChangedEventArgs<Color> newEventArgs =
        new RoutedPropertyChangedEventArgs<Color>(oldColor, newColor);
    newEventArgs.RoutedEvent = ColorPicker.SelectedColorChangedEvent;
    RaiseEvent(newEventArgs);
}

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker