FrameworkElement.IsLoaded 属性


获取一个值,该值指示是否已加载此元素以供呈现。Gets a value that indicates whether this element has been loaded for presentation.

 property bool IsLoaded { bool get(); };
public bool IsLoaded { get; }
member this.IsLoaded : bool
Public ReadOnly Property IsLoaded As Boolean


如果当前元素被附加到元素树,则为 true;如果该元素从未附加到所加载的元素树,则为 falsetrue if the current element is attached to an element tree; false if the element has never been attached to a loaded element tree.


下面的示例实现了两个处理程序:一个处理程序正在处理根元素的 Loaded 事件,因此,因为这是事件的重要性,所以请确保加载页面根元素。The following example implements two handlers: one is handling the Loaded event of the root element, so it is certain that the page root element is loaded because that is the significance of the event. 其他处理程序与用户控件挂钩,并调用 IsLoaded 以确保完全加载根元素。The other handler is hooked to a user control, and calls IsLoaded to assure that the root element is loaded completely. 这两个处理程序调用将用新数据填充子元素的相同函数(未显示)。Both handlers call the same function (not shown) that will populate child elements with fresh data.

private void OnLoad(object sender, RoutedEventArgs e)
private void updateSummary(object sender, RoutedEventArgs e)
    if (GroupBoxPage.IsLoaded)


从新构造的 FrameworkElement中,此属性将在设置为 true后开始 false,并保持 true,即使该元素随后通过代码从连接的逻辑树中删除也是如此。From a newly constructed FrameworkElement, this property starts off false, and remains true after it is set to true, even if the element is subsequently removed from a connected logical tree by code. 当元素加载到表示引擎时,true 状态由常规表示逻辑设置。true state is set by the general presentation logic when elements are loaded into the presentation engine.

通常情况下,将呈现加载的元素,但不是所有 FrameworkElement 派生类都有演示,其他属性(如 Visibility)可能会影响演示。Typically, loaded elements are rendered, but not all FrameworkElement derived classes have a presentation, and other properties such as Visibility can influence presentation.