FrameworkElement.BeginInit FrameworkElement.BeginInit FrameworkElement.BeginInit FrameworkElement.BeginInit Method

定義

啟動這個項目的初始化處理序 (Process)。Starts the initialization process for this element.

public:
 virtual void BeginInit();
public virtual void BeginInit ();
abstract member BeginInit : unit -> unit
override this.BeginInit : unit -> unit
Public Overridable Sub BeginInit ()

實作

備註

如果您要以尚未公開或連接專案至任何專案樹狀結構的方式來調整它們, 可以在個別專案上呼叫這個方法。You can call this method on individual elements if you are adjusting them in ways that do not yet expose or connect the element to any element tree. 例如, 您可能已建立新FrameworkElement的, 但尚未將它附加至任何邏輯樹狀結構。For instance, you might have created a new FrameworkElement, but have not yet attached it to any logical tree. 或者, 如果您的專案是其中元素的子專案, 邏輯樹狀結構可能不會連接到應用程式的視窗或頁面。Or, the logical tree where your element is a child element within it might not be connected to a window or page of the application.

給繼承者的注意事項

執行這個方法, 以提供在專案載入程式期間初始化專案之前, 應該發生的特殊處理。Implement this method to provide special handling that should happen before your element is initialized during the element loading process.

您的執行應該會呼叫基底實作為, 因為基底 (預設值) 會設定一些內部旗標來追蹤初始化。Your implementation should call the base implementation, because the base (default) implementation sets some internal flags to keep track of initialization. 其中一個可能的實作為, 使用這個方法作為您自己的私用類別初始化常式的連結, 這些程式尚未由函式啟用。One possible implementation is to use this method as a hook into your own private class initialization routines that are not already enabled by constructors.

如果BeginInit()在呼叫EndInit()之前于相同專案上呼叫多次, 基底執行將會擲回例外狀況。The base implementation will throw an exception if BeginInit() is called more than one time on the same element prior to EndInit() being called.

適用於

另請參閱