none
How to force Shape.RenderedGeometry to be updated ? RRS feed

  • Question

  •  

    Hi,

     

    I am trying to retrieve the rendered geometry of a shape defined in a xaml document.

    Is there a way to force the visual tree loaded from a document to update the RenderedGeometry of all the shapes without rendering anything on the screen ?

     

    Thanks in advance for any help

    Thursday, February 7, 2008 7:02 PM

Answers

  • You can explicitly trigger the measure and arrange pass by calling Shape.Measure() and Shape.Arrange() methods, this should be able to calculate the rendered geometry beforehand.

    Hope this helps
    Monday, February 11, 2008 6:03 AM

All replies

  • You can explicitly trigger the measure and arrange pass by calling Shape.Measure() and Shape.Arrange() methods, this should be able to calculate the rendered geometry beforehand.

    Hope this helps
    Monday, February 11, 2008 6:03 AM
  • Thanks for your reply Marco,

     

    This is the methods I ended up calling on each shape contained in the visual tree of my xaml document. However I was wondering if a simple call to UpdateLayout on the root element of the visual tree should be enough to force an update of all the shapes but unfortunatly it doesn't work as expected (RenderedGeometry is still empty)

     

    Any idea why UpdateLayout() on the root element doesn't force an update ?

     

    Thanks in advance

    Wednesday, February 13, 2008 8:51 PM
  • I think what UpdateLayout does is to place the measure and arrange requests into the measure queue and arrange queue, it doesn't trigger the layout pass immediately, that's why you need to explicitly trigger the layout by calling Measure() and Arrange() instead.

    Have you tried calling those two methods at parent element level? I suppose this should be able to do the trick.

    Hope this helps
    Thursday, February 14, 2008 2:11 AM
  • Thanks a lot Marco, It worked.

     

    The parameters taken by Measure and Arrange seems to be the size of the final render surface right ?

     

    Also the rendered geometry I am getting seems to not have any transformation applied to it. Is there a way to get the *final* screenspace transform of any UIElement ?

    I tried Geometry.Transform but it doesn't seem to give me the final matrix.

    Thursday, February 14, 2008 6:52 PM
  •  Philippe Rollin wrote:

    The parameters taken by Measure and Arrange seems to be the size of the final render surface right ?


    No, the parameter of Measure is the constrained parent size within which you want to allocate the layout space for the specified UIElement, the returned size of Measure will be the desired size of the UIElement, Arrange pass is actually responsible for calculating the rendered size for the UIElement, you could get more information on this from msdn documentation.

     Philippe Rollin wrote:


    Is there a way to get the *final* screenspace transform of any UIElement ?

    I tried Geometry.Transform but it doesn't seem to give me the final matrix.


    could you please elaborate a bit on what you mean by "*final* screenspace transform"?
    Do you mean the transform used to translate the coordinates from world coordinate system to device coordinate system?

    Thanks

    Friday, February 15, 2008 6:33 AM
  • Hi Marco,

     

    Sorry for the late reply. Just got back playing with this a little.

     

    I am still having trouble finding the final transformation of a visual/UIElement. When I say final transformation, I mean the transform matrix that translate/rotate/scale/shear the visual to the window corrdinate system. The VisualTreeHelper gives me the offset and the transform (why the transform doesn't already contain the offset ?).

    I would like to know if there is a way to easily retrieve the full transform of any element instead of having to compute it myself.

     

    Does that make sense ?

     

    Thanks in advance 

     

    Monday, March 10, 2008 9:35 PM
  • Have you tried Visual.TransformToAncestor(window)? this should give you a GeneralTransform relative to window's coordinate system.

    Hope this helps
    Tuesday, March 11, 2008 6:25 AM