UIElementCollection 類別

定義

代表已排序的 UIElement 子項目集合。

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

範例

下列範例會 Add 使用 方法,將子內容新增至父代 StackPanel 。 您可以使用 屬於 類型的 UIElementCollection 屬性來執行此動作 Children

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

備註

Panel 類會使用 來 UIElementCollection 表示其子專案的集合。 所 UIElementCollection 定義的方法和屬性會影響衍生自 Panel 的所有物件,並定義用於操作子項目的 Panel 通用功能集。

UIElementCollection具有本身內容 (類別) 的親和性。 您必須從擁有 Panel 的內容存取集合。

建構函式

UIElementCollection(UIElement, FrameworkElement)

初始化 UIElementCollection 類別的新執行個體。

屬性

Capacity

取得或設定 UIElementCollection 可包含的項目數目。

Count

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

IsSynchronized

取得值,這個值表示對 ICollection 介面的存取是否同步處理 (安全執行緒)。

Item[Int32]

取得或設定 UIElement,這個項目儲存在 UIElementCollection 之以零起始的索引位置。

SyncRoot

取得可用來同步處理對 ICollection 介面之存取的物件。

方法

Add(UIElement)

將指定的項目加入 UIElementCollection

Clear()

將所有項目從 UIElementCollection 移除。

ClearLogicalParent(UIElement)

當項目離開 UIElementCollection 時,會清除項目的邏輯父代。

Contains(UIElement)

判斷所指定的項目是否在 UIElementCollection 中。

CopyTo(Array, Int32)

從指定的索引位置開始,將 UIElementUIElementCollection 複製到陣列。

CopyTo(UIElement[], Int32)

從指定的索引位置開始,將 UIElementUIElementCollection 複製到陣列。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetEnumerator()

傳回可反覆查看 UIElementCollection 的列舉值。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
IndexOf(UIElement)

傳回 UIElementCollection 中指定項目的索引位置。

Insert(Int32, UIElement)

將項目插入 UIElementCollection 中指定的索引位置。

MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
Remove(UIElement)

將指定的項目從 UIElementCollection 中移除。

RemoveAt(Int32)

在指定的索引位置移除 UIElement

RemoveRange(Int32, Int32)

UIElementCollection 移除一個範圍的項目。

SetLogicalParent(UIElement)

UIElementCollection 中設定項目的邏輯父代。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

明確介面實作

IList.Add(Object)

這個類型或成員支援 Windows Presentation Foundation (WPF) 基礎結構,而且不能從程式碼直接使用。 如需這個成員的說明,請參閱 Add(Object)

IList.Contains(Object)

這個類型或成員支援 Windows Presentation Foundation (WPF) 基礎結構,而且不能從程式碼直接使用。 如需這個成員的說明,請參閱 Contains(Object)

IList.IndexOf(Object)

這個類型或成員支援 Windows Presentation Foundation (WPF) 基礎結構,而且不能從程式碼直接使用。 如需這個成員的說明,請參閱 IndexOf(Object)

IList.Insert(Int32, Object)

這個類型或成員支援 Windows Presentation Foundation (WPF) 基礎結構,而且不能從程式碼直接使用。 如需這個成員的說明,請參閱 Insert(Int32, Object)

IList.IsFixedSize

這個類型或成員支援 Windows Presentation Foundation (WPF) 基礎結構,而且不能從程式碼直接使用。 如需這個成員的說明,請參閱 IsFixedSize

IList.IsReadOnly

這個類型或成員支援 Windows Presentation Foundation (WPF) 基礎結構,而且不能從程式碼直接使用。 如需這個成員的說明,請參閱 IsReadOnly

IList.Item[Int32]

這個類型或成員支援 Windows Presentation Foundation (WPF) 基礎結構,而且不能從程式碼直接使用。 如需這個成員的說明,請參閱 Item[Int32]

IList.Remove(Object)

這個類型或成員支援 Windows Presentation Foundation (WPF) 基礎結構,而且不能從程式碼直接使用。 如需這個成員的說明,請參閱 Remove(Object)

擴充方法

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。

AsParallel(IEnumerable)

啟用查詢的平行化作業。

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryable

適用於

另請參閱