UIElement.OnChildDesiredSizeChanged(UIElement) 方法

定義

會在調整子項目的大小時支援配置行為。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

正在調整大小的子項目。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.

給繼承者的注意事項

OnChildDesiredSizeChanged(UIElement) 方法的預設實作為呼叫 InvalidateMeasure() 本身。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) 階段,則父代會重新計算版面配置。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.

適用於