FrameworkElement.Initialized FrameworkElement.Initialized FrameworkElement.Initialized FrameworkElement.Initialized Event

定義

當這個 FrameworkElement 初始化時發生。Occurs when this FrameworkElement is initialized. 這個事件符合 IsInitialized 屬性值從 false (或未定義) 變更為 true 的案例。This event coincides with cases where the value of the IsInitialized property changes from false (or undefined) to true.

public:
 event EventHandler ^ Initialized;
public event EventHandler Initialized;
member this.Initialized : EventHandler 
Public Custom Event Initialized As EventHandler 

備註

每當呼叫或EndInit OnVisualParentChanged方法時, 就會引發這個事件。This event will be raised whenever the EndInit or OnVisualParentChanged methods are called. 這兩種方法的呼叫可能來自應用程式代碼, 或在Extensible Application Markup Language (XAML)Extensible Application Markup Language (XAML)處理XAMLXAML頁面時透過處理器行為。Calls to either method could have come from application code, or through the Extensible Application Markup Language (XAML)Extensible Application Markup Language (XAML) processor behavior when a XAMLXAML page is processed.

您是否選擇處理LoadedInitialized取決於您的需求。Whether you choose to handle Loaded or Initialized depends on your requirements. 如果您不需要讀取元素屬性, 而想要重設屬性, 而且不需要任何版面配置資訊, Initialized則可能是要採取行動的較佳事件。If you do not need to read element properties, intend to reset properties, and do not need any layout information, Initialized might be the better event to act upon. 如果您需要專案的所有屬性都可供使用, 而且您將設定可能會重設配置的屬性, Loaded則可能是要採取行動的較佳事件。If you need all properties of the element to be available, and you will be setting properties that are likely to reset the layout, Loaded might be the better event to act upon. 如果您的處理常式重設了配置系統所解讀的任何屬性, 表示需要新的版面配置傳遞, 請小心重新進入。Be careful of reentrancy if your handler resets any properties that are interpreted by the layout system to mean that a new layout pass is required. (如果您不確定哪些屬性FrameworkPropertyMetadata可能需要新的版面配置傳遞 (如果有變更的話), 您可能需要檢查屬性的值)。(You might need to check the FrameworkPropertyMetadata values on the property if you are unsure of which properties can require a new layout pass if they are changed.)

如需的物件事件FrameworkElement順序, 以及數個相關應用程式和專案類別的詳細資訊, 請參閱物件存留期事件For more information about the sequence of object events for a FrameworkElement, and also for several related application and element classes, see Object Lifetime Events.

適用於

另請參閱