Share via


Layout.InitializeForContext(LayoutContext) Method

Definition

Initializes any per-container state the layout requires when it is attached to a UIElement container.

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

public:
 virtual void InitializeForContext(LayoutContext ^ context) = InitializeForContext;
void InitializeForContext(LayoutContext const& context);
public void InitializeForContext(LayoutContext context);
Public Sub InitializeForContext (context As LayoutContext)

Parameters

context
LayoutContext

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

Remarks

Container elements that support attached layouts should call this method when a layout instance is first assigned. The container is expected to give the attached layout instance a way to store and retrieve any per-container state by way of the provided context. It is also the responsibility of the container to not reuse the context, or otherwise expose the state from one layout to another.

When an attached layout is removed the container should release any reference to the layout state it stored.

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

Applies to

See also