FrameworkElement.MeasureOverride Method (Size)
When overridden in a derived class, measures the size in layout required for child elements and determines a size for the FrameworkElement-derived class.
Assembly: PresentationFramework (in PresentationFramework.dll)
The available size that this element can give to child elements. Infinity can be specified as a value to indicate that the element will size to whatever content is available.
Return ValueType: System.Windows.Size
The size that this element determines it needs during layout, based on its calculations of child element sizes.
Overrideto implement custom layout sizing behavior for your element as it participates in the Windows Presentation Foundation (WPF) layout system. Your implementation should do the following:
Iterate your element's particular collection of children that are part of layout, call Measure on each child element.
Compute the net desired size of the parent based upon the measurement of the child elements.
The return value ofshould be the element's own desired size, which then becomes the measure input for the parent element of the current element. This same process continues through the layout system until the root element of the page is reached.
During this process, child elements might return a larger DesiredSize size than the initial availableSize to indicate that the child element wants more space. This might be handled in your own implementation by introducing a scrollable region, by resizing the parent control, by establishing some manner of stacked order, or any number of solutions for measuring or arranging content.
Elements should call Measure on each child during this process, otherwise the child elements will not be correctly sized or arranged.
Notes to Inheritors:
The following non-compiling code shows this implementation pattern. VisualChildren represents an enumerable collection property of children that your own element should define. The property can be named anything. VisualChildren is a placeholder name for purposes of this example, VisualChildren is not an API as provided by WPF or a part of a naming pattern..
Available since 3.0
Available since 2.0
Windows Phone Silverlight
Available since 7.0