#758 – Access Actual Height and Width from within LayoutUpdated Event Handler

The ActualHeight and ActualWidth properties of a FrameworkElement can be read to get the values for the final height and width that the layout system assigned to the element.

The LayoutUpdated event of a UIElement (parent of FrameworkElement) will fire whenever the layout changes.  You can handle this event and read the values of ActualHeight and ActualWidth from within the handler.

You should typically only read these properties from within the LayoutUpdated handler.  If you try reading them at some other point, there’s no guarantee that they have arrived at their final values as a result of the layout changing.

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

One Response to #758 – Access Actual Height and Width from within LayoutUpdated Event Handler

  1. Pingback: Dew Drop – February 18, 2013 (#1,500) | Alvin Ashcraft's Morning Dew

Leave a comment