Share via


Layout.Measure(LayoutContext, Size) Method

Definition

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).

public:
 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

Parameters

context
LayoutContext

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

availableSize
Size

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.

Returns

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.

Remarks

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

Applies to