【发布时间】:2016-09-26 13:01:22
【问题描述】:
是否可以在椭圆绑定矩形中进行命中测试,like on this image?
【问题讨论】:
是否可以在椭圆绑定矩形中进行命中测试,like on this image?
【问题讨论】:
您可以将它们都放入 border 网格中并检查它是否被点击
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>
【讨论】: