0 out of 1 rated this helpful - Rate this topic

CommandBindingCollection Class

Represents a collection of CommandBinding objects.

System.Object
  System.Windows.Input.CommandBindingCollection

Namespace:  System.Windows.Input
Assembly:  PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
public sealed class CommandBindingCollection : IList, 
	ICollection, IEnumerable
<CommandBindingCollection .../>

The CommandBindingCollection type exposes the following members.

  Name Description
Public method CommandBindingCollection() Initializes a new instance of the CommandBindingCollection class.
Public method CommandBindingCollection(IList) Initializes a new instance of the CommandBindingCollection class using the items in the specified IList.
Top
  Name Description
Public property Count Gets the number of CommandBinding items in this CommandBindingCollection.
Public property IsFixedSize Gets a value indicating whether this CommandBindingCollection has a fixed size.
Public property IsReadOnly Gets a value indicating whether this CommandBindingCollection is read-only.
Public property IsSynchronized Gets a value indicating whether access to this CommandBindingCollection is synchronized (thread-safe).
Public property Item Gets or sets the CommandBinding at the specified index.
Public property SyncRoot Gets an object that can be used to synchronize access to the CommandBindingCollection.
Top
  Name Description
Public method Add Adds the specified CommandBinding to this CommandBindingCollection.
Public method AddRange Adds the items of the specified ICollection to the end of this CommandBindingCollection.
Public method Clear Removes all items from this CommandBindingCollection.
Public method Contains Determines whether the specified CommandBinding is in this CommandBindingCollection.
Public method CopyTo Copies all of the items in the CommandBindingCollection to the specified one-dimensional array, starting at the specified index of the target array.
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetEnumerator Gets an enumerator that iterates through this CommandBindingCollection.
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method IndexOf Searches for the first occurrence of the specified CommandBinding in this CommandBindingCollection.
Public method Insert Inserts the specified CommandBinding into this CommandBindingCollection at the specified index.
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method Remove Removes the first occurrence of the specified CommandBinding from this CommandBindingCollection.
Public method RemoveAt Removes the specified CommandBinding at the specified index of this CommandBindingCollection.
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Top
  Name Description
Public Extension Method AsParallel Enables parallelization of a query. (Defined by ParallelEnumerable.)
Public Extension Method AsQueryable Converts an IEnumerable to an IQueryable. (Defined by Queryable.)
Public Extension Method Cast<TResult> Converts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)
Public Extension Method OfType<TResult> Filters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)
Top
  Name Description
Explicit interface implemetation Private method ICollection.CopyTo Infrastructure. For a description of this member, see ICollection.CopyTo.
Explicit interface implemetation Private method IList.Add Infrastructure. For a description of this member, see IList.Add.
Explicit interface implemetation Private method IList.Contains Infrastructure. For a description of this member, see IList.Contains.
Explicit interface implemetation Private method IList.IndexOf Infrastructure. For a description of this member, see IList.IndexOf.
Explicit interface implemetation Private method IList.Insert Infrastructure. For a description of this member, see IList.Insert.
Explicit interface implemetation Private property IList.Item Infrastructure. For a description of this member, see IList.Item.
Explicit interface implemetation Private method IList.Remove Infrastructure. For a description of this member, see IList.Remove.
Top

All objects which derive from UIElement have a CommandBindingCollection named

CommandBindings .

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


.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ