开发者

Is there equivalent of WPF OriginalSource event property in Winform and ASP.NET?

开发者 https://www.devze.com 2023-02-06 19:25 出处:网络
From: http://www.wpfwiki.com/WPF%20Q14.12.ashx The OriginalSource property of the object identifies the original object

From:

http://www.wpfwiki.com/WPF%20Q14.12.ashx

The OriginalSource property of the object identifies the original object that received/initiated the event.

Consider a custom control (called CustomControl开发者_如何学Python1 in this example) that is composed of a TextBlock. When a MouseDown event is raised on the TextBlock, the OriginalSource property will be the TextBlock, but in CustomControl1's handler, the Source will be changed to the CustomControl1 object so that other elements along the event's route will know that CustomControl1 received a MouseDown.

Is there equivalent of WPF OriginalSource event property in Winform and ASP.NET ? If not how to emulate this ?


the "sender" argument which is sent to the event does not comfort your case, since you need another object to determine the container object which raised the event.

I emulate this by manually firing events either on server-side or on client-side through javascript.

Example: if a Span was inside a Div, on the, let's say, click event of the span, I call the click event on its container the div here. And then, in the event handler, the argument will be the div not the span.

Hope that helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号