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

前端 未结 5 1611
鱼传尺愫
鱼传尺愫 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:41

    button event Suppress the mousedown and mouseup because button event is high level event and have bit of code that give flag handle true this cause Suppressed for mousdown to resolve this problem you can add this code in constructor of window

    TheButton.AddHandler(
        UIElement.MouseDownEvent, 
        new MouseButtonEventHandler(TheStackPanel_MouseDown),
        true);
    

提交回复
热议问题