UIElement.ArrangeCore(Rect) 方法

定义

定义 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)

参数

finalRect
Rect

父级中应使用元素排列自身及其子元素的最终区域。The final area within the parent that element should use to arrange itself and its child elements.

示例

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

注解

备注

重写此方法仅适用于在 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.

继承者说明

如果要在 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.

适用于