FrameworkElement.Initialized 事件

定义

初始化此 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 

事件类型

EventHandler

注解

EndInit 调用或方法时,将引发此事件 OnVisualParentChangedThis event will be raised whenever the EndInit or OnVisualParentChanged methods are called. 对任一方法的调用都可以来自应用程序代码,或在处理 XAML 页时通过 Extensible Application Markup Language (XAML) 处理器行为。Calls to either method could have come from application code, or through the Extensible Application Markup Language (XAML) processor behavior when a XAML page is processed.

选择处理 Loaded 还是 Initialized 取决于您的需求。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.

适用于

另请参阅