ContentControl.HasContent Property

 

Gets a value that indicates whether the ContentControl contains content.

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

[BrowsableAttribute(false)]
public bool HasContent { get; }

Property Value

Type: System.Boolean

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

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

Identifier field

HasContentProperty

Metadata properties set to true

None

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");
    }
}

.NET Framework
Available since 3.0
Return to top
Show: