FrameworkElement.Initialized FrameworkElement.Initialized FrameworkElement.Initialized FrameworkElement.Initialized Event

定义

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

注解

当调用EndInitOnVisualParentChanged方法时, 将引发此事件。This event will be raised whenever the EndInit or OnVisualParentChanged methods are called. 对任一方法的调用都可以来自应用程序代码或处理可扩展应用程序标记语言 (XAML)Extensible Application Markup Language (XAML) XAMLXAML页时的处理器行为。Calls to either method could have come from application code, or through the 可扩展应用程序标记语言 (XAML)Extensible Application Markup Language (XAML) processor behavior when a XAMLXAML 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.

适用于

另请参阅