Why OnMouseDown handler exists but is not called for an ellipse?

时光毁灭记忆、已成空白 提交于 2019-12-13 05:49:13

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/4781942/why-onmousedown-handler-exists-but-is-not-called-for-an-ellipse

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!