UIElement.OnChildDesiredSizeChanged(UIElement) UIElement.OnChildDesiredSizeChanged(UIElement) UIElement.OnChildDesiredSizeChanged(UIElement) UIElement.OnChildDesiredSizeChanged(UIElement) Method

定义

重新调整子元素的大小时支持布局行为。Supports layout behavior when a child element is resized.

protected:
 virtual void OnChildDesiredSizeChanged(System::Windows::UIElement ^ child);
protected virtual void OnChildDesiredSizeChanged (System.Windows.UIElement child);
abstract member OnChildDesiredSizeChanged : System.Windows.UIElement -> unit
override this.OnChildDesiredSizeChanged : System.Windows.UIElement -> unit
Protected Overridable Sub OnChildDesiredSizeChanged (child As UIElement)

参数

child
UIElement UIElement UIElement UIElement

重新调整其大小的子元素。The child element that is being resized.

注解

此方法通常不由应用程序代码调用。This method is typically not called by your application code. 它是公开的, 因此派生元素类可以对其自身可能无效的布局状态进行进一步检查。It is exposed so that derived element classes can make further checks on their own possibly invalid layout state. 类还可以尝试进行优化, 以根据对子元素的大小更改, 最大程度地减少布局传递的处理时间。Classes could also attempt optimizations to minimize the processing time for a layout pass based on size changes to child elements. 实现OnChildDesiredSizeChanged的派生元素类示例Grid是控件。An example derived element class that implements OnChildDesiredSizeChanged is the Grid control.

继承者说明

方法具有对其自身调用InvalidateMeasure()的默认实现。 OnChildDesiredSizeChanged(UIElement)The OnChildDesiredSizeChanged(UIElement) method has the default implementation of calling InvalidateMeasure() on itself. 典型的实现应为: 执行你自己的元素支持的任何优化, 然后通常从OnChildDesiredSizeChanged(UIElement)至少一个代码分支 (表示每个你自己的度量值缓存逻辑的 "已更新" 状态的项) 调用基类。A typical implementation would be: do whatever optimization your own element supports, and then typically call base OnChildDesiredSizeChanged(UIElement) from at least one of the code branches (the one that indicated "dirty" state per your own measure caching logic).

如果此方法是产生大小更改的子本身, 则仅在布局处理中调用此方法。This method is only called in the layout processing if it was the child itself that originated the size changes. 否则, 如果父元素根据布局系统Measure(Size)规则启动了 pass, 则父元素已经重新计算布局。Otherwise, if the parent element initiates the Measure(Size) pass, according to the layout system rules, the parent is recalculating layout already. 布局系统将按子对象到父级的顺序处理布局, 因此不需要从子元素布局调用返回到父元素大小调整。The layout system processes layout in the order of child-to-parent, so no return to parent element sizing from the child element layout calls is necessary.

适用于