FrameworkElement.IsLoaded FrameworkElement.IsLoaded FrameworkElement.IsLoaded FrameworkElement.IsLoaded Property

定义

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

public:
 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)
{
    displayData();
}
private void updateSummary(object sender, RoutedEventArgs e)
{
    if (GroupBoxPage.IsLoaded)
        displayData();
}

注解

从新构造FrameworkElement的中, 此属性将false开始, 并且true在将其设置为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.

适用于

另请参阅