【问题标题】:How to retrieve the visible area/areas of a WPF control overlapped by other controls considering transparency?考虑到透明度,如何检索与其他控件重叠的 WPF 控件的可见区域/区域?
【发布时间】:2011-11-18 06:05:12
【问题描述】:

在考虑透明度的情况下,我需要确定与其他控件重叠的 WPF 控件的可见区域。

考虑以下场景:

画布上的三个控件。蓝色和绿色与第三​​个重叠。绿色的有一个透明的矩形区域。是否有可能有问题地获得由红色矩形标记的可见区域 1、2、3?

类似的东西(以下 API 不存在):

Geometry[] visibleAreas = VisualTreeHelper.GetVisibleGeometry(controlInTheBack);

提前感谢您的任何建议。

更新:

我尝试使用 DrawingGroup drawingGroup = VisualTreeHelper.GetDrawing(visual) 来获取每个控件的几何图形。

然后在重叠控件上使用CombinedGeometry with GeometryCombineMode="Union" 得到重叠区域。

然后在后面控件的几何与并集结果之间使用CombinedGeometry和GeometryCombineMode="Exclude"得到可见区域。

问题在于 VisualTreeHelper.GetDrawing(control) 返回 null。

【问题讨论】:

    标签: c# wpf xaml


    【解决方案1】:

    您是否已经尝试过使用 HitTest?可能会有帮助

    http://msdn.microsoft.com/en-us/library/ms752097.aspx

    【讨论】:

    猜你喜欢
    • 2010-12-26
    • 2011-03-13
    • 2019-12-15
    • 1970-01-01
    • 1970-01-01
    • 2014-01-13
    • 2016-12-17
    • 1970-01-01
    • 2012-08-13
    相关资源
    最近更新 更多