Skip to main content

The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets a value that indicates whether the ContentControl contains content.

Namespace:   System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

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

Property Value


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

If the property is null, this property returns false.

Identifier field


Metadata properties set to true


The following example shows how to use the 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
.NET Framework
Available since 3.0
Return to top