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 , 并将其添加CommandBindingCollectionWindow的。The 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)

注解

派生自UIElement的所有对象都有CommandBindingCollection一个名为All objects which derive from UIElement have a CommandBindingCollection named

CommandBindingsCommandBindings.

构造函数

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

获取此 CommandBinding 中的 CommandBindingCollection 项数。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 插入到此 CommandBindingCollection 的指定索引位置处。Inserts the specified CommandBinding into this CommandBindingCollection at the specified index.

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

创建当前 Object 的浅表副本。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).

扩展方法

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)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

适用于

另请参阅