FrameworkElement.LayoutUpdated 事件

定義

發生于視覺化樹狀結構的版面配置變更時,因為配置相關屬性會變更值或重新整理配置的其他一些動作。

// Register
event_token LayoutUpdated(EventHandler<IInspectable> const& handler) const;

// Revoke with event_token
void LayoutUpdated(event_token const* cookie) const;

// Revoke with event_revoker
FrameworkElement::LayoutUpdated_revoker LayoutUpdated(auto_revoke_t, EventHandler<IInspectable> const& handler) const;
public event System.EventHandler<object> LayoutUpdated;
function onLayoutUpdated(eventArgs) { /* Your code */ }
frameworkElement.addEventListener("layoutupdated", onLayoutUpdated);
frameworkElement.removeEventListener("layoutupdated", onLayoutUpdated);
- or -
frameworkElement.onlayoutupdated = onLayoutUpdated;
Public Custom Event LayoutUpdated As EventHandler(Of Object) 
<frameworkElement LayoutUpdated="eventhandler"/>
 

事件類型

備註

LayoutUpdated 是在控制項準備好進行互動之前,XAML 載入順序中要發生的最後一個物件存留期事件。 不過, LayoutUpdated 也可能在物件存留期期間于執行時間發生,原因有各種原因:屬性變更、視窗調整大小或執行時間配置要求, (UpdateLayout 或變更的控制項範本) 。 在配置順序中的所有SizeChanged事件發生之後,就會 LayoutUpdated 引發事件。

LayoutUpdated 當附加處理常式的物件不一定變更其下視覺化樹狀結構中的任何專案時,就會發生此情況。 例如,假設有兩個子項目共用空間的版面配置容器。 如果第一個物件變更了強制新版面配置的屬性,這兩個物件都會引發 LayoutUpdated,因為即使自己的子公司版面配置沒有變更,還是可能會重新置放第二個物件。

當您處理 LayoutUpdated 時,請勿依賴 傳送者 值。 針對 LayoutUpdated ,不論附加處理常式的位置為何, 傳送者 一律 null 為 。 這是為了防止處理常式將任何意義指派給 傳送者,例如,表示它是從視覺化樹狀結構引發事件的特定元素。 LayoutUpdated 表示整體視覺化樹狀結構中的某個專案已變更,而樹狀結構中任何位置的每個特定物件都有處理此出現的選項。 如果您熟悉較低層級的轉譯 API 設計,您可以將引發的類似 LayoutUpdated 「需要重繪」旗標設定為物件驅動、保留模式轉譯邏輯的一部分。

由於 LayoutUpdated 在許多情況下引發,而且不一定專屬於實際變更的物件,請考慮是否改為處理 SizeChanged 事件更適合您的案例。

適用於

另請參閱