WPF MouseLeftButtonUp 不触发 [英] WPF MouseLeftButtonUp Not Firing

查看:43
本文介绍了WPF MouseLeftButtonUp 不触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 MouseUp 事件时,我可以通过鼠标右键单击来触发它.但是 MouseLeftButtonUp 不会被任何一次点击触发!

When I use the MouseUp event, I can get it to fire with a mouse right-click. But MouseLeftButtonUp won't fire with either click!

<Button MouseLeftButtonUp="btnNewConfig_MouseUp"  Name="btnNewConfig">
    <StackPanel Orientation="Horizontal">
        <Image Source="Icons
ew.ico" Height="24" Width="24" Margin="5"/>
        <TextBlock VerticalAlignment="Center">New</TextBlock>
    </StackPanel>
</Button>

我知道这很可能很简单.感谢您的帮助!

I know this is most likely something simple. Thanks for the help!

推荐答案

看起来 Button 控件正在吃掉那个事件 因为 Button.Click 实际上是 Button.Click 的组合code>LeftButtonDown 事件和 LeftButtonUp 事件.

Looks like Button control is eating up that event Since Button.Click is actually a combination of LeftButtonDown event and LeftButtonUp event.

但是您可以订阅 Button 而不是 LeftButtonUp 上的隧道事件 PreviewMouseLeftButtonUp.

But you can subscribe to the tunneled event PreviewMouseLeftButtonUp on the Button instead of LeftButtonUp.

这篇关于WPF MouseLeftButtonUp 不触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆