Control -> Geometry

Hello, how do I convert control to Geometry

In order to perform VisualTreeHelper.HitTest and get an IntersectDetail I need to specify a Geometry, but I I have is just my poor control, which unfortunatly is a template-based one... So I can use any of hardocded geomtries like EllipseGeometry or whatever.

So, I'm looking for something:

Geomtry g = MyControl.GetGeometry(); :)

Thanks.



Answer this question

Control -> Geometry

  • Plow

    There is no existing service which does this, but you can theoretically implement it yourself:

    • Use VisualTreeHelper to walk the Visual tree of your Control.
    • On each Visual, call GetDrawing() to get the Drawing instructions associated with that Visual.
    • You can enumerate through the Drawing graph to get to the actual Geometries used.

    You'll need to pay attention to the Transform/Offset of the Visual, Drawings, and Geometry as you do this.

    - Daniel [msft]

    --

    All postings are provided "As Is" with no warranties, and confers no rights.


  • Control -> Geometry