[英]How to retrieve the visible area/areas of a WPF control overlapped by other controls considering transparency?
我需要考虑透明度来确定WPF控件的可见区域/区域与其他控件重叠。
请考虑以下情形:
画布上的三个控件。 蓝色和绿色与第三个重叠。 绿色的有一个透明的矩形区域。 是否有可能有问题地得到红色矩形标记的可见区域1,2,3?
类似的东西(以下API不存在):
Geometry[] visibleAreas = VisualTreeHelper.GetVisibleGeometry(controlInTheBack);
在此先感谢您的任何建议。
更新:
我试图使用DrawingGroup drawingGroup = VisualTreeHelper.GetDrawing(visual)来获取每个控件的几何。
然后在重叠控件上使用CombinedGeometry和GeometryCombineMode =“Union”来获取重叠区域。
然后在后面的控件的几何体和union的结果之间使用CombinedGeometry和GeometryCombineMode =“Exclude”来获得可见区域。
问题是VisualTreeHelper.GetDrawing(控件)返回null。
你有没有尝试过使用HitTest? 它可能会有所帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.