WPF Rectangle没有Click事件 [英] WPF Rectangle does not have a Click event

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

问题描述

似乎WPF 矩形形状没有定义Click事件。我应该使用什么?

It seems that the WPF Rectangle shape does not have the Click event defined. What am I supposed to use instead?

它有MouseUp,但它并不完全相同。

It does have MouseUp, but it's not quite the same behavior.

推荐答案

如果你不满意 MouseDown MouseUp ,也许你可以将 Rectangle 放在 Button 中,并处理 Button 单击事件?

If you're not happy with MouseDown and MouseUp, perhaps you could just put the Rectangle in a Button and handle the Button's Click event?

<Button>
    <Button.Template>
        <ControlTemplate>
            <Rectangle .../>
        </ControlTemplate>
    </Button.Template>
</Button>

这真的取决于你之后的行为。请详细说明是否需要。

It really depends with the behavior you're after. Please elaborate if needs be.

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

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