Why OnMouseDown handler exists but is not called f

2019-09-02 00:59发布

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条回答
Luminary・发光体
2楼-- · 2019-09-02 01:44

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.

查看更多
登录 后发表回答