The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

UIElementCollection.Count Property


Gets the actual number of elements in the collection.

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

public virtual int Count { get; }

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
© 2015 Microsoft