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


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

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



如果您正在調整它們的方式,尚未公開 (expose) 或連接到任何項目樹狀結構的項目,您可以在個別的項目上呼叫這個方法。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.