UIElementCollection 類別

定義

代表已排序的 UIElement 子項目集合。Represents an ordered collection of UIElement child elements.

public ref class UIElementCollection : System::Collections::IList
public class UIElementCollection : System.Collections.IList
type UIElementCollection = class
    interface IList
    interface ICollection
    interface IEnumerable
Public Class UIElementCollection
Implements IList
繼承
UIElementCollection
實作

範例

下列範例會使用Add方法, 將子內容新增至父系。 StackPanelThe following example uses the Add method to add child content to a parent StackPanel. 您可以使用Children屬性 (其類型UIElementCollection為) 來執行此動作。You do this by using the Children property, which is of type UIElementCollection.

void AddButton(object sender, MouseButtonEventArgs e)
{
    sp1.Children.Clear();
    btn = new Button();
    btn.Content = "New Button";
    sp1.Children.Add(btn);
}

備註

Panel基類會UIElementCollection使用來表示其子專案的集合。The Panel base class uses a UIElementCollection to represent its collection of child elements. 所定義的UIElementCollection方法和屬性會影響所有衍生自Panel的物件, 並定義用於操作Panel子項目的一般功能集。Methods and properties defined by the UIElementCollection affect all objects derived from Panel and define a common feature-set for the manipulation of Panel child elements.

與本身的內容 (類別)具有相似性。UIElementCollectionA UIElementCollection has affinity to its own context (class). 您必須從擁有Panel的內容存取集合。You must access the collection from the context of the owning Panel.

建構函式

UIElementCollection(UIElement, FrameworkElement)

初始化 UIElementCollection 類別的新執行個體。Initializes a new instance of the UIElementCollection class.

屬性

Capacity

取得或設定 UIElementCollection 可包含的項目數目。Gets or sets the number of elements that the UIElementCollection can contain.

Count

取得集合中的實際項目數量。Gets the actual number of elements in the collection.

IsSynchronized

取得值,這個值表示對 ICollection 介面的存取是否同步處理 (安全執行緒)。Gets a value that indicates whether access to the ICollection interface is synchronized (thread-safe).

Item[Int32]

取得或設定 UIElement,這個項目儲存在 UIElementCollection 之以零起始的索引位置。Gets or sets the UIElement stored at the zero-based index position of the UIElementCollection.

SyncRoot

取得可用來同步處理對 ICollection 介面之存取的物件。Gets an object that you can use to synchronize access to the ICollection interface.

方法

Add(UIElement)

將指定的項目加入 UIElementCollectionAdds the specified element to the UIElementCollection.

Clear()

將所有項目從 UIElementCollection 移除。Removes all elements from a UIElementCollection.

ClearLogicalParent(UIElement)

當項目離開 UIElementCollection 時,會清除項目的邏輯父代。Clears the logical parent of an element when the element leaves a UIElementCollection.

Contains(UIElement)

判斷所指定的項目是否在 UIElementCollection 中。Determines whether a specified element is in the UIElementCollection.

CopyTo(Array, Int32)

從指定的索引位置開始,將 UIElementUIElementCollection 複製到陣列。Copies a UIElement from a UIElementCollection to an array, starting at a specified index position.

CopyTo(UIElement[], Int32)

從指定的索引位置開始,將 UIElementUIElementCollection 複製到陣列。Copies a UIElement from a UIElementCollection to an array, starting at a specified index position.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetEnumerator()

傳回可反覆查看 UIElementCollection 的列舉值。Returns an enumerator that can iterate the UIElementCollection.

GetHashCode()

作為預設雜湊函數。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
IndexOf(UIElement)

傳回 UIElementCollection 中指定項目的索引位置。Returns the index position of a specified element in a UIElementCollection.

Insert(Int32, UIElement)

將項目插入 UIElementCollection 中指定的索引位置。Inserts an element into a UIElementCollection at the specified index position.

MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
Remove(UIElement)

將指定的項目從 UIElementCollection 中移除。Removes the specified element from a UIElementCollection.

RemoveAt(Int32)

移除在指定索引處的 UIElementRemoves the UIElement at the specified index.

RemoveRange(Int32, Int32)

UIElementCollection 移除一個範圍的項目。Removes a range of elements from a UIElementCollection.

SetLogicalParent(UIElement)

UIElementCollection 中設定項目的邏輯父代。Sets the logical parent of an element in a UIElementCollection.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

明確介面實作

IList.Add(Object)

這個類型或成員支援 Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) 基礎結構,而且不能從程式碼直接使用。This type or member supports the Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. 如需這個成員的說明,請參閱 Add(Object)For a description of this member, see Add(Object).

IList.Contains(Object)

這個類型或成員支援 Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) 基礎結構,而且不能從程式碼直接使用。This type or member supports the Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. 如需這個成員的說明,請參閱 Contains(Object)For a description of this member, see Contains(Object).

IList.IndexOf(Object)

這個類型或成員支援 Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) 基礎結構,而且不能從程式碼直接使用。This type or member supports the Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. 如需這個成員的說明,請參閱 IndexOf(Object)For a description of this member, see IndexOf(Object).

IList.Insert(Int32, Object)

這個類型或成員支援 Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) 基礎結構,而且不能從程式碼直接使用。This type or member supports the Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. 如需這個成員的說明,請參閱 Insert(Int32, Object)For a description of this member, see Insert(Int32, Object).

IList.IsFixedSize

這個類型或成員支援 Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) 基礎結構,而且不能從程式碼直接使用。This type or member supports the Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. 如需這個成員的說明,請參閱 IsFixedSizeFor a description of this member, see IsFixedSize.

IList.IsReadOnly

這個類型或成員支援 Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) 基礎結構,而且不能從程式碼直接使用。This type or member supports the Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. 如需這個成員的說明,請參閱 IsReadOnlyFor a description of this member, see IsReadOnly.

IList.Item[Int32]

這個類型或成員支援 Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) 基礎結構,而且不能從程式碼直接使用。This type or member supports the Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. 如需這個成員的說明,請參閱 Item[Int32]For a description of this member, see Item[Int32].

IList.Remove(Object)

這個類型或成員支援 Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) 基礎結構,而且不能從程式碼直接使用。This type or member supports the Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. 如需這個成員的說明,請參閱 Remove(Object)For a description of this member, see Remove(Object).

擴充方法

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

啟用查詢的平行化作業。Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryableConverts an IEnumerable to an IQueryable.

適用於

另請參閱