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.

適用於

另請參閱