WPF。椭圆 "rectangle bounds" hittest 有可能吗?

WPF. Is it possible to do ellipse "rectangle bounds" hittest?

是否可以在椭圆边界矩形中进行命中测试,like on this image?

您可以将它们都放入 边框 网格中并检查它是否被点击

XAML:

            <Grid MouseDown="Border_MouseDown">
                <Rectangle Width="100"
                           Height="100"
                           Fill="Green" />
                <Ellipse Width="100"
                         Height="100"
                         Fill="Orange" />
            </Grid>

代码隐藏

   private void Border_MouseDown(object sender, MouseButtonEventArgs e)
        {
            MessageBox.Show("hit it");
        }

编辑 只是为了使它完整这里只有绿色区域的 XAML:

   <Grid>
            <Rectangle Width="100"
                       Height="100"
                       Fill="Green"
                       MouseDown="Border_MouseDown" />
            <Ellipse Width="100"
                     Height="100"
                     Fill="Orange" />
        </Grid>