UIElementCollection.Count 屬性

定義

取得集合中的實際項目數量。

public:
 virtual property int Count { int get(); };
public virtual int Count { get; }
member this.Count : int
Public Overridable ReadOnly Property Count As Integer

屬性值

集合中的實際項目數量。

實作

範例

下列範例會 Count 使用 屬性來計算 中的 UIElementCollection 子專案數目。

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

適用於