Public Class UIElementCollection Implements IList, ICollection, IEnumerable
Dim instance As UIElementCollection
public class UIElementCollection : IList, ICollection, IEnumerable
public ref class UIElementCollection : IList, ICollection, IEnumerable
public class UIElementCollection implements IList, ICollection, IEnumerable
このマネージ クラスは XAML では使用できません。
Panel 基本クラスでは、UIElementCollection を使用して子要素のコレクションが表されます。UIElementCollection で定義されるメソッドとプロパティは、Panel 子要素を操作するための共通機能セットを定義し、Panel から派生したすべてのオブジェクトに影響します。
UIElementCollection には、自身のコンテキスト (クラス) に対するアフィニティがあります。このコレクションへのアクセスは、このコレクションが属する Panel のコンテキストから行う必要があります。
Add メソッドを使用して、親 StackPanel に子コンテンツを追加する方法を次の例に示します。この作業には、UIElementCollection 型の Children プロパティを使用します。サンプル全体については、「要素の使用のサンプル」を参照してください。
void AddButton(object sender, MouseButtonEventArgs e) { sp1.Children.Clear(); btn = new Button(); btn.Content = "New Button"; sp1.Children.Add(btn); }