[This documentation is preliminary and is subject to change.]
Positions child objects and determines a size for a UIElement. Parent objects that implement custom layout for their child elements should call this method from their layout override implementations to form a recursive layout update.
Syntax
Parameters
- finalRect
-
Type: Rect
The final size that the parent computes for the child in layout, provided as a Rect value.
Remarks
The Arrange call potentially reaches an ArrangeOverride implementation of that specific class. Otherwise, most FrameworkElement classes have an implicit default layout behavior for Arrange.
Examples
This example shows how you would use Arrange within an ArrangeOverride implementation. The basic idea is that you should query DesiredSize on anything you attempt to call Arrange on so that you have a value for finalRect, unless your layout implementation has some specific design that alters or ignores the desired size before passing it as finalRect.
// Second arrange all children and return final size of panel protected override Size ArrangeOverride(Size finalSize) { // Get the collection of children UIElementCollection mychildren = Children; // Get total number of children int count = mychildren.Count; // Arrange children // We're only allowing 9 children in this panel. More children will get a 0x0 layout slot. int i; for (i = 0; i < 9; i++) { // Get (left, top) origin point for the element in the 3x3 block Point cellOrigin = GetOrigin(i, 3, new Size(100, 100)); // Arrange child // Get desired height and width. This will not be larger than 100x100 as set in MeasureOverride. double dw = mychildren[i].DesiredSize.Width; double dh = mychildren[i].DesiredSize.Height; mychildren[i].Arrange(new Rect(cellOrigin.X, cellOrigin.Y, dw, dh)); } // Give the remaining children a 0x0 layout slot for (i = 9; i < count; i++) { mychildren[i].Arrange(new Rect(0, 0, 0, 0)); } // Return final size of the panel return new Size(300, 300); }
Requirements
|
Minimum supported client | Windows 8 Release Preview |
|---|---|
|
Minimum supported server | Windows Server 2012 |
|
Namespace |
|
|
Metadata |
|
See also
Build date: 5/22/2012
