InputBindingCollection InputBindingCollection InputBindingCollection InputBindingCollection Class

定义

表示 InputBinding 对象的有序集合。Represents an ordered collection of InputBinding objects.

public ref class InputBindingCollection sealed : System::Collections::IList
public sealed class InputBindingCollection : System.Collections.IList
type InputBindingCollection = class
    interface IList
    interface ICollection
    interface IEnumerable
Public NotInheritable Class InputBindingCollection
Implements IList
继承
InputBindingCollectionInputBindingCollectionInputBindingCollectionInputBindingCollection
实现

示例

下面的示例创建一个KeyGesture , 并将其KeyBinding与关联。The following example creates a KeyGesture and associates it with a KeyBinding. 将添加到中InputBindingCollection Window的。 KeyBindingThe KeyBinding is added to the InputBindingCollection on a Window.

<Window.InputBindings>
  <KeyBinding Key="B"
              Modifiers="Control" 
              Command="ApplicationCommands.Open" />
</Window.InputBindings>
KeyGesture OpenKeyGesture = new KeyGesture(
    Key.B,
    ModifierKeys.Control);

KeyBinding OpenCmdKeybinding = new KeyBinding(
    ApplicationCommands.Open,
    OpenKeyGesture);

this.InputBindings.Add(OpenCmdKeybinding);
Dim OpenKeyGesture As New KeyGesture(Key.B, ModifierKeys.Control)

Dim OpenCmdKeybinding As New KeyBinding(ApplicationCommands.Open, OpenKeyGesture)

Me.InputBindings.Add(OpenCmdKeybinding)

注解

派生自UIElement的所有对象都具有InputBindingCollection一个InputBindings名为的。All objects that derive from UIElement have an InputBindingCollection named InputBindings. 派生自ContentElement的所有对象都具有InputBindingCollection一个InputBindings名为的。All objects that derive from ContentElement have an InputBindingCollection named InputBindings.

但是, 如果在中XAMLXAML设置这些集合, 则集合中的项必须是派生InputBinding类, 而不是直接InputBinding对象。However, if these collections are set in XAMLXAML, then the items in the collection must be derived classes of InputBinding rather than direct InputBinding objects. 这是因为InputBinding不支持默认公共构造函数。This is because InputBinding does not support a default public constructor. 因此, InputBindingCollection在中XAMLXAML设置的项通常是InputBinding一个KeyBinding支持默认公共构造函数的派生类, 如或MouseBindingTherefore, the items in a InputBindingCollection that was set in XAMLXAML will typically be an InputBinding derived class that does support a default public constructor, such as KeyBinding or MouseBinding.

构造函数

InputBindingCollection() InputBindingCollection() InputBindingCollection() InputBindingCollection()

初始化 InputBindingCollection 类的新实例。Initializes a new instance of the InputBindingCollection class.

InputBindingCollection(IList) InputBindingCollection(IList) InputBindingCollection(IList) InputBindingCollection(IList)

使用指定的 InputBindingCollection 中的项初始化 IList 类的新实例。Initializes a new instance of the InputBindingCollection class using the items in the specified IList.

属性

Count Count Count Count

获取此集合中的 InputBinding 项数。Gets the number of InputBinding items in this collection.

IsFixedSize IsFixedSize IsFixedSize IsFixedSize

获取一个值,该值指示此 InputBindingCollection 是否具有固定大小。Gets a value that indicates whether this InputBindingCollection has a fixed size.

IsReadOnly IsReadOnly IsReadOnly IsReadOnly

获取一个值,该值指示此 InputBindingCollection 是否为只读。Gets a value that indicates whether this InputBindingCollection is read-only.

IsSynchronized IsSynchronized IsSynchronized IsSynchronized

获取一个值,该值指示是否同步对此 InputBindingCollection 的访问(线程安全)。Gets a value indicating whether access to this InputBindingCollection is synchronized (thread-safe).

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

获取或设置指定索引处的 InputBindingGets or sets the InputBinding at the specified index.

SyncRoot SyncRoot SyncRoot SyncRoot

获取可用于同步对 InputBindingCollection 的访问的对象。Gets an object that can be used to synchronize access to the InputBindingCollection.

方法

Add(InputBinding) Add(InputBinding) Add(InputBinding) Add(InputBinding)

将指定的 InputBinding 添加到此 InputBindingCollectionAdds the specified InputBinding to this InputBindingCollection.

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

将指定的 ICollection 的项添加到此 InputBindingCollection 的末尾Adds the items of the specified ICollection to the end of this InputBindingCollection

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

移除此 InputBindingCollection 中的所有项。Removes all items from this InputBindingCollection.

Contains(InputBinding) Contains(InputBinding) Contains(InputBinding) Contains(InputBinding)

确定指定的 InputBinding 是否位于此 InputBindingCollection 中。Determines whether the specified InputBinding is in this InputBindingCollection

CopyTo(InputBinding[], Int32) CopyTo(InputBinding[], Int32) CopyTo(InputBinding[], Int32) CopyTo(InputBinding[], Int32)

InputBindingCollection 中的所有项复制到指定的一维数组(从目标数组的指定索引处开始)。Copies all of the items in the InputBindingCollection 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()

获取一个循环访问此 InputBindingCollection 的枚举器。Gets an enumerator that iterates through this InputBindingCollection.

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

在此 InputBinding 中搜索指定 InputBindingCollection 的第一个匹配项。Searches for the first occurrence of the specified InputBinding in his InputBindingCollection.

Insert(Int32, InputBinding) Insert(Int32, InputBinding) Insert(Int32, InputBinding) Insert(Int32, InputBinding)

将指定的 InputBinding 插入到此 InputBindingCollection 的指定索引位置处。Inserts the specified InputBinding into this InputBindingCollection at the specified index.

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

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
Remove(InputBinding) Remove(InputBinding) Remove(InputBinding) Remove(InputBinding)

从此 InputBinding 中移除指定的 InputBindingCollection 的第一个匹配项。Removes the first occurrence of the specified InputBinding from this InputBindingCollection.

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

从此 InputBinding 的指定索引处移除指定的 InputBindingCollectionRemoves the specified InputBinding at the specified index of this InputBindingCollection.

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.

适用于

另请参阅