Height and Width of a Scaled Object RRS feed

  • Question

  • How do you go about obtaining the height and width of a UI object, say a rectangle, that's been scaled down or up? 


    I have tried the Height, Width, ActualHeight, ActualWidth, RenderSize and even the mis-named DesiredSize method.  I've tried to obtain it after Loaded, SizeChanged, LayoutUpdated and animation Completed events.  I've checked the object itself and the StackPanel that contains the object.



    Tuesday, May 27, 2008 6:08 PM


  • RenderTransforms happen at render time. Most of the rest of the system is unaware of RenderTransforms--they will not be reflected in the Width, ActualWidth, etc. properties. An exception to this is the input system, which will take transforms into account when raising input events.

    You can use the Transform method of the RenderTransform (cast it to a MatrixTransform first). Try giving it a point that is the scaled elements Width and Height.

    Tuesday, May 27, 2008 6:28 PM