RoutedEventArgs 類別

定義

包含與路由事件相關聯的狀態資訊和事件資料。

/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 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(Windows.Foundation.UniversalApiContract), 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
繼承
Object IInspectable RoutedEventArgs
衍生
屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

備註

RoutedEventArgs 是一種常見的事件資料類型,用於使用 C++、C# 或 Visual Basic 在 UWP app 中的基底元素事件。 一般而言,RoutedEventArgs 為事件資料類型,表示具有此事件資料的事件是 路由事件,但有一些例外狀況。 如需路由事件及其處理方式的詳細資訊,請參閱 事件和路由事件概觀

RoutedEventArgs 新增至一般化事件資料集的 API 是 OriginalSourceOriginalSource 可用於判斷第一次引發事件以進行點擊測試和事件路由案例的專案,但有時候來自委派簽章的 傳送者 是處理常式更實用的來源物件參考。 如需詳細資訊,請參閱事件與路由事件概觀

RoutedEventArgs 和 Handled 屬性

如果您熟悉WINDOWS PRESENTATION FOUNDATION (WPF) ,您可能會知道Windows Presentation Foundation (WPF) 在 RoutedEventArgs 類別上宣告名為Handled的屬性。 Windows 執行階段中的特定路由事件資料類別也會定義Handled屬性,而且使用的方式與在 WPF Windows Presentation Foundation (中所做的相同方式) (它會影響處理常式內的事件路由。) 不過,對於Windows 執行階段此外,對於 Microsoft Silverlight,此行為僅適用于特定路由事件,而不是所有路由事件, (如同在 Windows Presentation Foundation (WPF) ) 中所示。 例如,如果您正在處理指標事件,而事件資料類別是PointerRoutedEventArgs,但無法針對事件資料為 RoutedEventArgs 實例的Loaded事件設定Handled

RoutedEventArgs 衍生類別

RoutedEventArgs 是數個立即衍生類別的父類別,可定義涉及 UI 元素之Windows 執行階段事件的事件資料。 並非所有類別提供資料的事件都必須路由事件,如 事件和路由事件概觀中所定義。 但許多都是。 由於相容性原因,這些事件資料有時沒有衍生自 RoutedEventArgs 的事件資料。

建構函式

RoutedEventArgs()

初始化 RoutedEventArgs 類別的新實例。

屬性

OriginalSource

取得引發事件之 物件的參考。 這通常是控制項的範本部分,而不是在應用程式 UI 中宣告的專案。

適用於

另請參閱