FrameworkElement.EndInit 方法


指示元素的初始化过程已完成。Indicates that the initialization process for the element is complete.

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



调用 EndInit() 之前尚未在元素上调用 BeginInit()EndInit() was called without BeginInit() having previously been called on the element.


如果之前调用了 BeginInit,则基实现将引发 Initialized 事件。If BeginInit was previously called, the base implementation will raise the Initialized event. 否则,如果未调用 BeginInit 或无法确定是否调用了 BeginInit,则不会引发 Initialized,而是会引发异常。Otherwise, if BeginInit was not called or it could not be determined whether BeginInit was called, Initialized is not raised and an exception is thrown instead.


实现此方法可提供在元素加载过程中初始化元素时应发生的特殊处理。Implement this method to provide special handling that should happen when 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.