I need to determine the visible area/areas of a WPF control overlapped by other controls taking in consideration transparency.
Consider the following scenario:
Three controls on a canvas. The blue and the green one are overlapping the third one. The green one has a transparent rectangle area. Is it possible to problematically get the visible regions 1, 2, 3 marked by red rectangles?
Something similar to (following API doesn't exist):
Geometry[] visibleAreas = VisualTreeHelper.GetVisibleGeometry(controlInTheBack);
Thanks in advance for any suggestions.
Update:
I've tried to use DrawingGroup drawingGroup = VisualTreeHelper.GetDrawing(visual) to get the geometries of each control.
Then use CombinedGeometry with GeometryCombineMode="Union" on the overlapping controls to get the overlapping area.
Then use CombinedGeometry with GeometryCombineMode="Exclude" between the geometry of the control in the back and the result of the union to obtain the visible regions.
The problem is that VisualTreeHelper.GetDrawing(control) returns null.