UIElement.ArrangeCore(Rect) Method

Definition

定義 WPF 核心層級排列版面配置定義的範本。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 的執行應該會呼叫基底實值來傳回大小,然後呼叫每個可見子專案的 Arrange 方法,並使用基底實值的大小來協調這些 Arrange 呼叫所傳回的大小。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. 視元素的版面配置特性而定,ArrangeCore 執行的「對等」方面的邏輯可能會有所不同。The logic for the reconciliation aspect of a ArrangeCore implementation might vary, depending on the layout characteristics of your element. 在下列範例範本中,VisualChildren 是假設的屬性,您的元素可能會定義它來協助列舉其內容;UIElement 不會在此層級定義內容集合,WPF 架構層級架構會將內容行為延遲到衍生的元素,例如特定控制項或控制項基類。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

只有當您在 WPF 核心層級衍生,而且不使用 WPF 架構層級版面配置系統和 FrameworkElement 衍生類別時,才會覆寫這個方法,因為 FrameworkElement 會密封 ArrangeCoreOverriding 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. 如果您使用 WPF 架構層級的版面配置系統,則會 ArrangeOverride用於覆寫類別特定版面配置排列行為的適當方法。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

如果您正在開發 WPF 核心層級的專案,您應該覆寫此方法,讓 WPF 核心層級元素成為唯一的排列版面配置行為,或對專案的子項目做出適當的版面配置決策。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. 如果無法從定義的模式(例如 ItemCollection)識別這些子項目,則可能需要覆寫。An override might be necessary if those child elements are not recognizable from a defined pattern such as an ItemCollection.

父元素必須在每個子專案上呼叫類別特定的 Arrange(Rect),否則不會轉譯這些子專案。A parent element must call the class-specific Arrange(Rect) on each child element, otherwise those child elements are not rendered.

Applies to