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

定义

启动此元素的初始化过程。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.

适用于

另请参阅