如何检索WPF控件的可见区域/区域,考虑透明度并被其他控件重叠?

4
我需要确定在考虑透明度的情况下,WPF控件被其他控件重叠时的可见区域/区域。
考虑以下场景: enter image description here 画布上有三个控件。蓝色和绿色控件重叠第三个控件。绿色控件具有透明矩形区域。是否可能以编程方式获取由红色矩形标记的可见区域1、2、3?
类似于(以下API不存在):
Geometry[] visibleAreas = VisualTreeHelper.GetVisibleGeometry(controlInTheBack);

感谢您的建议。
更新:
我尝试使用DrawingGroup drawingGroup = VisualTreeHelper.GetDrawing(visual)来获取每个控件的几何形状。
然后在重叠的控件上使用CombinedGeometry和GeometryCombineMode="Union"来获取重叠区域。
然后在后面的控件的几何形状和联合结果之间使用CombinedGeometry和GeometryCombineMode="Exclude"来获取可见区域。
问题是VisualTreeHelper.GetDrawing(control)返回null。
1个回答

1

该链接已不再可用 :( - M.Kumaran
这是新链接 https://learn.microsoft.com/zh-cn/dotnet/framework/wpf/graphics-multimedia/hit-testing-in-the-visual-layer - ilCosmico

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接