RoutedEventArgs.Source RoutedEventArgs.Source RoutedEventArgs.Source RoutedEventArgs.Source Property

定義

取得或設定引發事件之物件的參考。Gets or sets a reference to the object that raised the event.

public:
 property System::Object ^ Source { System::Object ^ get(); void set(System::Object ^ value); };
public object Source { get; set; }
member this.Source : obj with get, set
Public Property Source As Object

屬性值

引發事件的物件。The object that raised the event.

備註

針對任何事件反昇路由已實際周遊至之外引發的項目路由的事件,在任何通道路由事件不具有尚未引發它的值的項目到通道Source會比的值不同sender參數的事件引數類別。For any bubbling routed event that has actually traveled the route beyond the element that raised it, and for any tunneling routed event that has not yet tunneled down to the element that raised it, the value of Source will be different than the value of the sender parameter of the event arguments class. 事件牽涉到的兩個元素中, 哪一個是最重要的, 就是任何Source指定的處理常式 (、引發它sender的專案或目前正在處理它的元素), 都取決於您處理常式的應用程式邏輯。根源.Which of the two elements involved in the event is of the most importance in any given handler (Source, the element that raised it, or sender, the element that is currently handling it) is dependent on the application logic that your handler is addressing.

設定這個屬性通常只會在覆寫或執行調整APIAPIs事件來源的其他專案時完成, 例如在處理事件的類別時。Setting this property is typically only done when overriding or implementing other APIAPIs that adjust event sources, such as when class handling an event. 不建議從實例處理常式重設明顯的事件來源, 特別是當處理常式不會將事件標示為已處理時。Resetting apparent event sources from instance handlers is not recommended, particularly when the handler does not mark the event as handled.

如果您重設Source以報告不同的事件來源, OriginalSource將會繼續以原始RaiseEvent呼叫所引發的第一個來源來報告來源。If you do reset Source to report a different event source, OriginalSource will continue to report the source as first raised by the originating RaiseEvent call.

適用於

另請參閱