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.

通常仅在重写或实现调整事件源的其他APIs (如处理事件的类时), 才能设置此属性。Setting this property is typically only done when overriding or implementing other APIs 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.

适用于

另请参阅