FrameworkElement::ArrangeOverride Method
When overridden in a derived class, positions child elements and determines a size for a FrameworkElement derived class.
Assembly: PresentationFramework (in PresentationFramework.dll)
Parameters
- finalSize
- Type: System.Windows::Size
The final area within the parent that this element should use to arrange itself and its children.
Control authors who want to customize the arrange pass of layout processing should override this method. The implementation pattern should call Arrange on each visible child element, and pass the final desired size for each child element as the finalRect parameter. Parent elements should call Arrange on each child, otherwise the child elements will not be rendered.
Many derived classes offer implementations of this method. Prominent ones include: Window::ArrangeOverride, Page::ArrangeOverride and Control::ArrangeOverride.
This example shows how to override the default layout behavior of the Panel element and create custom layout elements that are derived from Panel.
The example defines a simple custom Panel element called PlotPanel, which positions child elements according to two hard-coded x- and y-coordinates. In this example, x and y are both set to 50; therefore, all child elements are positioned at that location on the x and y axes.
To implement custom Panel behaviors, the example uses the MeasureOverride and ArrangeOverride methods. Each method returns the Size data that is necessary to position and render child elements.
public: ref class PlotPanel : Panel { public: PlotPanel () {}; protected: // Override the default Measure method of Panel virtual Size MeasureOverride(Size availableSize) override { Size^ panelDesiredSize = gcnew Size(); // In our example, we just have one child. // Report that our panel requires just the size of its only child. for each (UIElement^ child in InternalChildren) { child->Measure(availableSize); panelDesiredSize = child->DesiredSize; } return *panelDesiredSize ; } protected: virtual System::Windows::Size ArrangeOverride (Size finalSize) override { for each (UIElement^ child in InternalChildren) { double x = 50; double y = 50; child->Arrange(Rect(Point(x, y), child->DesiredSize)); } return finalSize; }; };
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.