Redigera

Dela via


UIElement.ArrangeCore(Rect) Method

Definition

Defines the template for WPF core-level arrange layout definition.

protected:
 virtual void ArrangeCore(System::Windows::Rect finalRect);
protected virtual void ArrangeCore (System.Windows.Rect finalRect);
abstract member ArrangeCore : System.Windows.Rect -> unit
override this.ArrangeCore : System.Windows.Rect -> unit
Protected Overridable Sub ArrangeCore (finalRect As Rect)

Parameters

finalRect
Rect

The final area within the parent that element should use to arrange itself and its child elements.

Examples

ArrangeCore implementations should call the base implementation to return a size, then call the Arrange method of each visible child element, and reconcile the sizes returned by these Arrange calls with the size of the base implementation. The logic for the reconciliation aspect of a ArrangeCore implementation might vary, depending on the layout characteristics of your element. In the following example template, VisualChildren is a hypothetical property that your element might define to help enumerate its content; UIElement does not define content collections at this level, the WPF framework-level architecture defers content behavior to derived elements such as specific controls or control base classes.

protected override void ArrangeCore(Rect finalRect)
{
     //Call base, it will set offset and RenderBounds to the finalRect:
     base.ArrangeCore(finalRect);
     foreach (UIElement child in VisualChildren)
     {
         child.Arrange(new Rect(childX, childY, childWidth, childHeight));
     }
 }
Protected Overrides Sub ArrangeCore(ByVal finalRect As Rect)
     'Call base, it will set offset and RenderBounds to the finalRect:
     MyBase.ArrangeCore(finalRect)
     For Each child As UIElement In VisualChildren
         child.Arrange(New Rect(childX, childY, childWidth, childHeight))
     Next child
End Sub

Remarks

Note

Overriding this method is only appropriate if you are deriving at the WPF core-level, and you are not using the WPF framework-level layout system and FrameworkElement derived class, because FrameworkElement seals ArrangeCore. If you are using the WPF framework-level layout system, the appropriate method to override for class-specific layout arrange behavior is ArrangeOverride.

Notes to Inheritors

If you are developing elements at the WPF core level,you should override this method to give your WPF core-level element a unique arrange layout behavior, or to make proper layout decisions about the child elements of your elements. An override might be necessary if those child elements are not recognizable from a defined pattern such as an ItemCollection.

A parent element must call the class-specific Arrange(Rect) on each child element, otherwise those child elements are not rendered.

Applies to