CommandBindingCollection Class
Definition
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 ICollection
interface IEnumerable
interface IList
type CommandBindingCollection = class
interface IList
interface ICollection
interface IEnumerable
Public NotInheritable Class CommandBindingCollection
Implements IList
- Inheritance
-
CommandBindingCollection
- Implements
Examples
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)
Remarks
All objects which derive from UIElement have a CommandBindingCollection named
Constructors
CommandBindingCollection() |
Initializes a new instance of the CommandBindingCollection class. |
CommandBindingCollection(IList) |
Initializes a new instance of the CommandBindingCollection class using the items in the specified IList. |
Properties
Count |
Gets the number of CommandBinding items in this CommandBindingCollection. |
IsFixedSize |
Gets a value indicating whether this CommandBindingCollection has a fixed size. |
IsReadOnly |
Gets a value indicating whether this CommandBindingCollection is read-only. |
IsSynchronized |
Gets a value indicating whether access to this CommandBindingCollection is synchronized (thread-safe). |
Item[Int32] |
Gets or sets the CommandBinding at the specified index. |
SyncRoot |
Gets an object that can be used to synchronize access to the CommandBindingCollection. |
Methods
Add(CommandBinding) |
Adds the specified CommandBinding to this CommandBindingCollection. |
AddRange(ICollection) |
Adds the items of the specified ICollection to the end of this CommandBindingCollection. |
Clear() |
Removes all items from this CommandBindingCollection. |
Contains(CommandBinding) |
Determines whether the specified CommandBinding is in this CommandBindingCollection. |
CopyTo(CommandBinding[], Int32) |
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) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
GetEnumerator() |
Gets an enumerator that iterates through this CommandBindingCollection. |
GetHashCode() |
Serves as the default hash function. (Inherited from Object) |
GetType() |
Gets the Type of the current instance. (Inherited from Object) |
IndexOf(CommandBinding) |
Searches for the first occurrence of the specified CommandBinding in this CommandBindingCollection. |
Insert(Int32, CommandBinding) |
Inserts the specified CommandBinding into this CommandBindingCollection at the specified index. |
MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |
Remove(CommandBinding) |
Removes the first occurrence of the specified CommandBinding from this CommandBindingCollection. |
RemoveAt(Int32) |
Removes the specified CommandBinding at the specified index of this CommandBindingCollection. |
ToString() |
Returns a string that represents the current object. (Inherited from Object) |
Explicit Interface Implementations
ICollection.CopyTo(Array, Int32) |
For a description of this member, see CopyTo(Array, Int32). |
IList.Add(Object) |
For a description of this member, see Add(Object). |
IList.Contains(Object) |
For a description of this member, see Contains(Object). |
IList.IndexOf(Object) |
For a description of this member, see IndexOf(Object). |
IList.Insert(Int32, Object) |
For a description of this member, see Insert(Int32, Object). |
IList.Item[Int32] |
For a description of this member, see Item[Int32]. |
IList.Remove(Object) |
For a description of this member, see Remove(Object). |
Extension Methods
Cast<TResult>(IEnumerable) |
Casts the elements of an IEnumerable to the specified type. |
OfType<TResult>(IEnumerable) |
Filters the elements of an IEnumerable based on a specified type. |
AsParallel(IEnumerable) |
Enables parallelization of a query. |
AsQueryable(IEnumerable) |
Converts an IEnumerable to an IQueryable. |