Compartir a través de


IXRFrameworkElement::AddLayoutUpdatedEventHandler (Compact 2013)

3/28/2014

This method attaches a delegate to the LayoutUpdated event for this framework element. When this framework element raises the LayoutUpdated event, this delegate is invoked.

Syntax

virtual HRESULT STDMETHODCALLTYPE AddLayoutUpdatedEventHandler(
  __in IXRDelegate<XREventArgs>* pDelegate
) = 0;

Parameters

  • pDelegate
    [in] Pointer to an IXRDelegate<ArgType, [SenderType]> object that you want to attach to the LayoutUpdated event, for handling the event that occurs when the layout of the XAML for Windows Embedded visual tree changes.

Return Value

Returns an HRESULT that indicates success or failure.

Remarks

Multiple delegates can be attached to the same event.

To remove this delegate from the LayoutUpdated event, call IXRFrameworkElement::RemoveLayoutUpdatedEventHandler.

LayoutUpdated is the last object lifetime event to occur in the sequence prior to a control being ready for interaction. However, LayoutUpdated also can occur at run time during the object lifetime, for a variety of reasons: a property change, a window resizing, or an explicit request (UpdateLayout or ApplyTemplate). LayoutUpdated fires after all possible SizeChanged events in the tree have fired.

LayoutUpdated can occur in cases where the object to which the handler is attached does not necessarily change anything in the visual tree under it. For instance, imagine a layout container where there are two elements. If the first object changes a property that forces a new layout, then both objects raise LayoutUpdated, because the second object might be repositioned even if its own subsidiary layout does not change.

When you handle LayoutUpdated, do not rely on the sender value. For LayoutUpdated, sender is always a null reference, regardless of where the handler is attached. This is to prevent handlers from assigning any meaning to sender, such as implying that it was that specific element that raised the event out of the visual tree. Rather, LayoutUpdated implies that something in the overall XAML for Windows Embedded visual tree has changed, and each specific object anywhere in the tree has the option of handling this occurrence.

.NET Framework Equivalent

System.Windows.FrameworkElement.LayoutUpdated

Requirements

Header

XamlRuntime.h,
XRDelegate.h

sysgen

SYSGEN_XAML_RUNTIME

See Also

Reference

IXRFrameworkElement