RoutedEventArgs Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Contains state information and event data associated with a routed event.
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.UI.Xaml.WinUIContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class RoutedEventArgs
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.UI.Xaml.WinUIContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public class RoutedEventArgs
Public Class RoutedEventArgs
- Inheritance
- Derived
- Attributes
Remarks
RoutedEventArgs
is a common event data type used for base element events in Windows App SDK apps using C++ or C#. Generally RoutedEventArgs
as the event data type indicates that the event with this event data is a routed event, although there are some exceptions. For more info on routed events and how to handle them, see Events and routed events overview.
The API that RoutedEventArgs
adds to a generalized event data set is OriginalSource. OriginalSource
can be useful for determining the element that first raised the event for hit testing and event routing scenarios, but there are also times where the sender from the delegate signature is the more useful source object reference for a handler. For more info, see Events and routed events overview.
RoutedEventArgs and the Handled property
If you're familiar with Windows Presentation Foundation (WPF), you might know that WPF declares a property named Handled
on the RoutedEventArgs
class. Certain routed event data classes in the Windows Runtime also define a Handled
property, and you use it the same way you did in WPF (it influences the event route from within your handler.) However, for Windows App SDK this behavior is specific only to certain routed events rather than all routed events (as is true in WPF). For example, you can set Handled if you are handling a pointer event and the event data class is PointerRoutedEventArgs, but you can't set Handled
for a Loaded event where the event data is a RoutedEventArgs instance.
RoutedEventArgs derived classes
RoutedEventArgs
is the parent class for several immediately derived classes that define event data for Windows Runtime events involving UI elements. Not all of the events where the classes provide data are necessarily routed events as defined in Events and routed events overview. But many are. The ones that aren't sometimes have the event data derived from RoutedEventArgs
for compatibility reasons.
- DragEventArgs
- ExceptionRoutedEventArgs
- SizeChangedEventArgs
- CleanUpVirtualizedItemEventArgs
- ContextMenuEventArgs
- ItemClickEventArgs
- SelectionChangedEventArgs
- TextChangedEventArgs
- DragCompletedEventArgs
- DragDeltaEventArgs
- DragStartedEventArgs
- RangeBaseValueChangedEventArgs
- ScrollEventArgs
- HyperlinkClickEventArgs
- DoubleTappedRoutedEventArgs
- HoldingRoutedEventArgs
- KeyRoutedEventArgs
- ManipulationCompletedRoutedEventArgs
- ManipulationDeltaRoutedEventArgs
- ManipulationInertiaStartingRoutedEventArgs
- ManipulationStartedRoutedEventArgs
- ManipulationStartingRoutedEventArgs
- PointerRoutedEventArgs
- RightTappedRoutedEventArgs
- TappedRoutedEventArgs
Constructors
RoutedEventArgs() |
Initializes a new instance of the RoutedEventArgs class. |
Properties
OriginalSource |
Gets a reference to the object that raised the event. This is often a template part of a control rather than an element that was declared in your app UI. |