为什么 OnMouseDown 处理程序存在但不调用椭圆? [英] Why OnMouseDown handler exists but is not called for an ellipse?

查看:27
本文介绍了为什么 OnMouseDown 处理程序存在但不调用椭圆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个椭圆(在 UserControl 的网格内)并为 MouseDown 创建了这个事件处理程序,但为什么它从未被调用?

I have an ellipse (inside a grid of a UserControl) and created this event handler for MouseDown but why it is never called ?

    private void ellipse1_MouseDown(object sender, MouseButtonEventArgs e)
    {
        MessageBox.Show("Ellipse");
    }

我在椭圆内没有孩子,所以不涉及事件冒泡.这是疯狂的行为.

I have no children inside the ellipse so there is no event bubbling involved. This is crazy behavior.

推荐答案

默认情况下,椭圆上的填充"和其他形状为空.如果您将其设置为任何颜色(甚至是透明的),您会发现单击它会为您提供所需的行为.或者,如果您单击边缘上的现有椭圆(带有空填充),您将获得事件.

By default the 'Fill' on an ellipse, and other shapes is null. If you set it to any color at all (even transparent), you fill find that clicking on it will give you the behavior that you desire. Alternatively, if you click the existing ellipse (with null fill) just on the edge, you will get your event.

这篇关于为什么 OnMouseDown 处理程序存在但不调用椭圆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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