UIElementCollection UIElementCollection UIElementCollection UIElementCollection Class

定義

代表已排序的 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
繼承
UIElementCollectionUIElementCollectionUIElementCollectionUIElementCollection
實作

範例

下列範例會使用Add方法,以將子內容加入至父代StackPanelThe following example uses the Add method to add child content to a parent StackPanel. 您可以使用Children屬性,這是型別的UIElementCollectionYou 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.

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

建構函式

UIElementCollection(UIElement, FrameworkElement) UIElementCollection(UIElement, FrameworkElement) UIElementCollection(UIElement, FrameworkElement) UIElementCollection(UIElement, FrameworkElement)

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

屬性

Capacity Capacity Capacity Capacity

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

Count Count Count Count

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

IsSynchronized IsSynchronized IsSynchronized IsSynchronized

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

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

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

SyncRoot SyncRoot SyncRoot SyncRoot

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

方法

Add(UIElement) Add(UIElement) Add(UIElement) Add(UIElement)

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

Clear() Clear() Clear() Clear()

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

ClearLogicalParent(UIElement) ClearLogicalParent(UIElement) ClearLogicalParent(UIElement) ClearLogicalParent(UIElement)

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

Contains(UIElement) Contains(UIElement) Contains(UIElement) Contains(UIElement)

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

CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32)

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

CopyTo(UIElement[], Int32) CopyTo(UIElement[], Int32) CopyTo(UIElement[], Int32) CopyTo(UIElement[], Int32)

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

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

(Inherited from Object)
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

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

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

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

(Inherited from Object)
IndexOf(UIElement) IndexOf(UIElement) IndexOf(UIElement) IndexOf(UIElement)

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

Insert(Int32, UIElement) Insert(Int32, UIElement) Insert(Int32, UIElement) Insert(Int32, UIElement)

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

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
Remove(UIElement) Remove(UIElement) Remove(UIElement) Remove(UIElement)

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

RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32)

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

RemoveRange(Int32, Int32) RemoveRange(Int32, Int32) RemoveRange(Int32, Int32) RemoveRange(Int32, Int32)

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

SetLogicalParent(UIElement) SetLogicalParent(UIElement) SetLogicalParent(UIElement) SetLogicalParent(UIElement)

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

ToString() ToString() ToString() ToString()

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

(Inherited from Object)

明確介面實作

IList.Add(Object) IList.Add(Object) IList.Add(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) IList.Contains(Object) IList.Contains(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) IList.IndexOf(Object) IList.IndexOf(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) IList.Insert(Int32, Object) IList.Insert(Int32, 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 IList.IsFixedSize IList.IsFixedSize 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 IList.IsReadOnly IList.IsReadOnly 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] IList.Item[Int32] IList.Item[Int32] 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) IList.Remove(Object) IList.Remove(Object) 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).

Extension Methods

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

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

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

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

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

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

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

將轉換IEnumerableIQueryableConverts an IEnumerable to an IQueryable.

適用於

另請參閱