Share via

Layout.Measure(LayoutContext, Size) Method


Suggests a DesiredSize for a container element. A container element that supports attached layouts should call this method from their own MeasureOverride implementations to form a recursive layout update. The attached layout is expected to call the Measure for each of the container’s UIElement children.

This documentation applies to WinUI 2 for UWP (for WinUI in the Windows App SDK, see the Windows App SDK namespaces).

 virtual Size Measure(LayoutContext ^ context, Size availableSize) = Measure;
Size Measure(LayoutContext const& context, Size const& availableSize);
public Size Measure(LayoutContext context, Size availableSize);
Public Function Measure (context As LayoutContext, availableSize As Size) As Size



The context object that facilitates communication between the layout and its host container.


The available space that a container can allocate to a child object. A child object can request a larger space than what is available; the provided size might be accommodated if scrolling or other resize behavior is possible in that particular container.


The size that this object determines it needs during layout, based on its calculations of the allocated sizes for child objects or based on other considerations such as a fixed container size.


Override NonVirtualizingLayout.MeasureOverride or VirtualizingLayout.MeasureOverride to provide the behavior for this method in a derived class.

Applies to