Why doesn't button click event “bubble up visual tree” to StackPanel as MSDN article states?

前端 未结 5 1623
鱼传尺愫
鱼传尺愫 2021-02-12 09:49

In the MSDN article Understanding Routed Events and Commands In WPF, it states

an event will bubble (propagate) up the visual tree from the source ele

5条回答
  •  天涯浪人
    2021-02-12 10:38

    The event bubbles up, until it gets handled...

    Since the Button does something with your mouse clicks, it absorbs your mouse event and turns it into a ClickEvent.

    If you use the PreviewMouseDown, you see that the StackPanel first receives the event before the button does.. Preview events use the Tunnel down approach..

提交回复
热议问题