ContentControl.HasContent 屬性

定義

取得值,這個值表示 ContentControl 是否包含內容。Gets a value that indicates whether the ContentControl contains content.

public:
 property bool HasContent { bool get(); };
[System.ComponentModel.Browsable(false)]
public bool HasContent { get; }
[<System.ComponentModel.Browsable(false)>]
member this.HasContent : bool
Public ReadOnly Property HasContent As Boolean

屬性值

Boolean

如果 ContentControl 有內容則為 true,否則為 falsetrue if the ContentControl has content; otherwise false. 預設值是 falseThe default value is false.

屬性

範例

下列範例顯示如何使用 HasContent 屬性來判斷內容控制項是否包含內容。The following example shows how to use the HasContent property to determine whether a content control contains content.

void OnClick(object sender, RoutedEventArgs e)
{
    if (contCtrl.HasContent == true)
    {
        MessageBox.Show("contCtrl has content");
    }
}
Private Sub OnClick(ByVal Sender As Object, ByVal e As RoutedEventArgs)

    If (contCtrl.HasContent = True) Then
        MessageBox.Show("contCtrl has content")
    End If

End Sub

備註

如果 Content 屬性為 null ,則這個屬性會傳回 falseIf the Content property is null, this property returns false.

相依性屬性資訊Dependency Property Information

識別碼欄位Identifier field HasContentProperty
中繼資料屬性設定為 trueMetadata properties set to true NoneNone

適用於