locked
Bubble and Tunnel events handling RoutedEventArgs RRS feed

  • Question

  • I'm new in WPF and I found this new Concept "Bubble" and "Tunnel" events, I read about this events and I understand how them work. But, I was wondering, How a control can Trigger the container's event???, in other words, If I try to develop some code in Windows forms or a Console application to aproach this goal, How can I do that?, because, the only way to trigger the Container's event is expousse a public member to trigger it, and that could be a problem because, any other object could trigger the event with no reason. 

    The other question is, if I code a new "Bubble or Tunnel" event, there is not reason to do that, because, default controls don't have this event, just if my container is a Custom control as well, right?

    I thought the solution could be a "friend" member like C++ but C# doesn't have this functionality.
    • Moved by CoolDadTx Thursday, July 2, 2020 3:15 PM WPF related
    Thursday, July 2, 2020 5:06 AM

All replies

  • ... and I found this new Concept "Bubble" and "Tunnel" events

    Well, it's not exactly new. Maybe if you had only done desktop applications before. But the concept of bubbling events already existed before WPF in HTML applications. Events in your HTML pages also bubble like in WPF.

    I thought the solution could be a "friend" member like C++ but C# doesn't have this functionality.

    Well, there is something similar. In C# you can use the internal accessibility (instead of private or public) to declare a method or an event that is only visible to other types that are compiled into the same assembly. In this way you can control the "any other object could trigger the event with no reason", because "any other object" would mean "only the objects that I compiled into my assembly" -- external objects will not be able to do so.

    Thursday, July 2, 2020 5:43 AM
  • Hi JuanC_LopGar97,
    Based on your description, it is mostly related to WPF. So it is recommended to ask the questions in Microsoft Q&A forum and you can get more professional answer.
    Thank you for your understanding.
    Best Regards,
    Daniel Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, July 2, 2020 8:22 AM