ContentControl.HasContent Property


Gets a value that indicates whether the ContentControl contains content.

 property bool HasContent { bool get(); };
public bool HasContent { get; }
member this.HasContent : bool
Public ReadOnly Property HasContent As Boolean

Property Value


true if the ContentControl has content; otherwise false. The default value is false.



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


If the Content property is null, this property returns false.

Dependency Property Information

Identifier field HasContentProperty
Metadata properties set to true None

Applies to