【发布时间】:2013-07-14 00:10:13
【问题描述】:
我在 XAML 中有这个矩形:
<Rectangle x:Name="MyRectangle" Height="300" Width="300"></Rectangle>
我想检查它是否与另一个矩形相交。在this question on SO 中,他们说必须使用IntersectsWith method。 但我无法在代码隐藏中使用它。当我用 C# 编写时:
MyRectangle.IntersectsWith(
我得到标准错误:
“System.Windows.Shapes.Rectangle 不包含 'IntersectsWith' 的定义并且没有扩展方法 [...]”
我认为这是因为XAML中的矩形是System.Windows.Shapes.Rectangle,而方法是System.Windows.Rect?如果是这样,有没有办法将我的Rectangle“转换”为Rect?
【问题讨论】:
标签: wpf xaml hittest rectangles