FrameworkContentElement.IsLoaded 屬性

定義

取得值,這個值表示此項目是否已載入以供展示。Gets a value indicating 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 and has been rendered; false if the element has never been attached to a loaded element tree.

範例

下列範例程式碼會使用 IsLoaded 做為條件式檢查,以確保 displayData (未顯示)的函式會在要處理的頁面上載入有效的元素,做為視需要處理常式的一部分。The following example code uses IsLoaded as a conditional check to assure that a function displayData (not shown) will have valid elements loaded on the page to work against, as part of an on-demand handler. 該相同的邏輯會當做 Loaded的事件處理常式來執行。That same logic is run as an event handler for Loaded.

private void OnLoad(object sender, RoutedEventArgs e)
{
    displayData();
}
private void updateSummary(object sender, RoutedEventArgs e)
{
    if (myflowdocument.IsLoaded)
        displayData();
}
Private Sub OnLoad(ByVal sender As Object, ByVal e As RoutedEventArgs)
    displayData()
End Sub
Private Sub updateSummary(ByVal sender As Object, ByVal e As RoutedEventArgs)
    If myflowdocument.IsLoaded Then
        displayData()
    End If
End Sub

備註

從新建立的實例中,這個屬性會從 false開始,並且會在設定為 true時保持 true,即使之後程式碼已移除也一樣。From a newly constructed instance, this property starts off false, and remains true once it is set to true, even if subsequently removed by code.

適用於

另請參閱