CommandBindingCollection CommandBindingCollection CommandBindingCollection CommandBindingCollection Class

定義

表示 CommandBinding 物件的集合。Represents a collection of CommandBinding objects.

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

範例

下列範例會建立CommandBinding並將它加入CommandBindingCollectionWindowThe following example creates a CommandBinding and adds it to the CommandBindingCollection of a Window.

<Window x:Class="SDKSamples.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:custom="clr-namespace:SDKSamples"
    Height="600" Width="800"
    >
  <Window.CommandBindings>
    <CommandBinding Command="{x:Static custom:Window1.CustomRoutedCommand}"
                    Executed="ExecutedCustomCommand"
                    CanExecute="CanExecuteCustomCommand" />
  </Window.CommandBindings>
CommandBinding customCommandBinding = new CommandBinding(
    CustomRoutedCommand, ExecutedCustomCommand, CanExecuteCustomCommand);

// attach CommandBinding to root window
this.CommandBindings.Add(customCommandBinding);
Dim customCommandBinding As New CommandBinding(CustomRoutedCommand, AddressOf ExecutedCustomCommand, AddressOf CanExecuteCustomCommand)

' attach CommandBinding to root window
Me.CommandBindings.Add(customCommandBinding)

備註

所有的物件衍生自UIElementCommandBindingCollection名為All objects which derive from UIElement have a CommandBindingCollection named

CommandBindings.CommandBindings.

建構函式

CommandBindingCollection() CommandBindingCollection() CommandBindingCollection() CommandBindingCollection()

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

CommandBindingCollection(IList) CommandBindingCollection(IList) CommandBindingCollection(IList) CommandBindingCollection(IList)

使用指定之 CommandBindingCollection 中的項目,初始化 IList 類別的新執行個體。Initializes a new instance of the CommandBindingCollection class using the items in the specified IList.

屬性

Count Count Count Count

取得這個 CommandBindingCommandBindingCollection 項目的數目。Gets the number of CommandBinding items in this CommandBindingCollection.

IsFixedSize IsFixedSize IsFixedSize IsFixedSize

取得值,指出這個 CommandBindingCollection 是否有固定的大小。Gets a value indicating whether this CommandBindingCollection has a fixed size.

IsReadOnly IsReadOnly IsReadOnly IsReadOnly

取得值,指出這個 CommandBindingCollection 是否為唯讀。Gets a value indicating whether this CommandBindingCollection is read-only.

IsSynchronized IsSynchronized IsSynchronized IsSynchronized

取得值,指出對這個 CommandBindingCollection 的存取是否已同步處理 (安全執行緒)。Gets a value indicating whether access to this CommandBindingCollection is synchronized (thread-safe).

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

取得或設定在指定索引處的 CommandBindingGets or sets the CommandBinding at the specified index.

SyncRoot SyncRoot SyncRoot SyncRoot

取得可用以同步存取 CommandBindingCollection 的物件。Gets an object that can be used to synchronize access to the CommandBindingCollection.

方法

Add(CommandBinding) Add(CommandBinding) Add(CommandBinding) Add(CommandBinding)

將指定的 CommandBinding 加入至這個 CommandBindingCollectionAdds the specified CommandBinding to this CommandBindingCollection.

AddRange(ICollection) AddRange(ICollection) AddRange(ICollection) AddRange(ICollection)

將指定 ICollection 的項目加入至這個 CommandBindingCollection 的結尾。Adds the items of the specified ICollection to the end of this CommandBindingCollection.

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

將所有項目從這個 CommandBindingCollection 移除。Removes all items from this CommandBindingCollection.

Contains(CommandBinding) Contains(CommandBinding) Contains(CommandBinding) Contains(CommandBinding)

判斷指定的 CommandBinding 是否在這個 CommandBindingCollection 中。Determines whether the specified CommandBinding is in this CommandBindingCollection.

CopyTo(CommandBinding[], Int32) CopyTo(CommandBinding[], Int32) CopyTo(CommandBinding[], Int32) CopyTo(CommandBinding[], Int32)

CommandBindingCollection 中的所有項目複製到指定的一維陣列,從目標陣列的指定索引開始。Copies all of the items in the CommandBindingCollection to the specified one-dimensional array, starting at the specified index of the target array.

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()

取得可逐一查看這個 CommandBindingCollection 的列舉程式。Gets an enumerator that iterates through this CommandBindingCollection.

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(CommandBinding) IndexOf(CommandBinding) IndexOf(CommandBinding) IndexOf(CommandBinding)

在這個 CommandBinding 中搜尋指定之 CommandBindingCollection 的第一個項目。Searches for the first occurrence of the specified CommandBinding in this CommandBindingCollection.

Insert(Int32, CommandBinding) Insert(Int32, CommandBinding) Insert(Int32, CommandBinding) Insert(Int32, CommandBinding)

將指定之 CommandBinding 插入位於指定索引的這個 CommandBindingCollectionInserts the specified CommandBinding into this CommandBindingCollection at the specified index.

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

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

(Inherited from Object)
Remove(CommandBinding) Remove(CommandBinding) Remove(CommandBinding) Remove(CommandBinding)

從這個 CommandBinding 移除指定之 CommandBindingCollection 的第一個項目。Removes the first occurrence of the specified CommandBinding from this CommandBindingCollection.

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

從這個 CommandBinding 的指定索引處移除指定的 CommandBindingCollectionRemoves the specified CommandBinding at the specified index of this CommandBindingCollection.

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

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

(Inherited from Object)

明確介面實作

ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32)

如需這個成員的說明,請參閱 CopyTo(Array, Int32)For a description of this member, see CopyTo(Array, Int32).

IList.Add(Object) IList.Add(Object) IList.Add(Object) IList.Add(Object)

如需這個成員的說明,請參閱 Add(Object)For a description of this member, see Add(Object).

IList.Contains(Object) IList.Contains(Object) IList.Contains(Object) IList.Contains(Object)

如需這個成員的說明,請參閱 Contains(Object)For a description of this member, see Contains(Object).

IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object)

如需這個成員的說明,請參閱 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)

如需這個成員的說明,請參閱 Insert(Int32, Object)For a description of this member, see Insert(Int32, Object).

IList.Item[Int32] IList.Item[Int32] IList.Item[Int32] IList.Item[Int32]

如需這個成員的說明,請參閱 Item[Int32]For a description of this member, see Item[Int32].

IList.Remove(Object) IList.Remove(Object) IList.Remove(Object) IList.Remove(Object)

如需這個成員的說明,請參閱 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.

適用於

另請參閱