Difference between Bubbling and Tunneling events

后端 未结 2 441
既然无缘
既然无缘 2020-12-08 14:36

What is the exact difference between Bubbling Events and Tunneling events? Where should I use Bubbling Events and where should I use Tunneling events? Thanks in Advance!

2条回答
  •  暖寄归人
    2020-12-08 15:18

    As a start: the naming convention in WPF for some default events is Preview for tunneling and for bubbling. So for example for the KeyDown we would have PreviewKeyDown and KeyDown, tunneling and bubbling respectively.

    The difference between the two, as the naming convention implies, is that a tunneling event will start at the highest node in the tree (probably the Window) and going down to the lowest child. A bubbling event will start at the child and then go upwards again.

    This guide should explain it clearly: http://www.codeproject.com/Articles/464926/To-bubble-or-tunnel-basic-WPF-events

提交回复
热议问题