ContentControl.HasContent ContentControl.HasContent ContentControl.HasContent ContentControl.HasContent Property

定义

获取一个值,该值指示 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; }
member this.HasContent : bool
Public ReadOnly Property HasContent As 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

注解

如果属性为null, 则此属性返回falseContentIf the Content property is null, this property returns false.

依赖项属性信息Dependency Property Information

标识符字段Identifier field HasContentProperty
元数据属性设置为trueMetadata properties set to true NoneNone

适用于