UIElementCollection.Count Property


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

Gets the actual number of elements in the collection.

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

Public Overridable ReadOnly Property Count As Integer

Property Value

Type: System.Int32

The actual number of elements in the collection.

The following example uses the Count property to count the number of child elements in a UIElementCollection.

void GetCount(object sender, RoutedEventArgs e)
    TextBlock txt3 = new TextBlock();
    txt3.Text = "UIElement Count is equal to " + sp1.Children.Count.ToString();

.NET Framework
Available since 3.0
Return to top