.NET Framework Class Library
InputBinding..::.CommandParameter Property

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Gets or sets the command-specific data for a particular command.

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
Syntax

Visual Basic (Declaration)
Public Property CommandParameter As Object
    Get
    Set
Visual Basic (Usage)
Dim instance As InputBinding
Dim value As Object

value = instance.CommandParameter

instance.CommandParameter = value
C#
public Object CommandParameter { get; set; }
Visual C++
public:
virtual property Object^ CommandParameter {
    Object^ get () sealed;
    void set (Object^ value) sealed;
}
F#
abstract CommandParameter : Object with get, set
override CommandParameter : Object with get, set
XAML Property Element Usage
<inputBindingDerivedClass>
  <inputBindingDerivedClass.CommandParameter>
    <commandParameterObject/>
  </inputBindingDerivedClass.CommandParameter>
</inputBindingDerivedClass>
XAML Attribute Usage
<inputBindingDerivedClass CommandParameter="commandParameterString"/>

XAML Values

inputBindingDerivedClass

A derived class of InputBinding that supports object element syntax, such as KeyBinding or MouseBinding. See Remarks.

commandParameterString

A string that is processed by a particular command. Strings are the common type used for command parameters because they can be easily set in XAML. For the expected string format and its purpose, see the documentation for the particular command that the input binding is associated with. Many commands do not expect parameters.

commandParameterObject

An object that is processed by a particular command. All existing WPF commands use strings, so this property element syntax is only relevant for custom command scenarios. In order to support this syntax, the commandParameterObject object must also support object element syntax (must have a public default constructor).

Property Value

Type: System..::.Object
The command-specific data. The default is nullNothingnullptra null reference (Nothing in Visual Basic).

Implements

ICommandSource..::.CommandParameter
Remarks

The CommandParameter property is used to pass specific information to the command when it is executed. The type of the data is defined by the command. Many commands do not expect command parameters; for these commands, any command parameters passed will be ignored.

If the command that an input binding is associated with is a RoutedCommand, the CommandParameter of the input binding is passed to the RoutedCommand handlers through the ExecutedRoutedEventArgs and the CanExecuteRoutedEventArgs event data when the command is processed.

The data type and purpose of the command parameter are defined differently for each command, and can be nullNothingnullptra null reference (Nothing in Visual Basic).

The InputBinding class itself does not support XAML usage, because it does not expose a public default constructor (there is a default constructor, but it is protected). However, derived classes can expose a public constructor and thus can set properties that are inherited from InputBinding with a XAML usage. Two existing InputBinding derived classes that can be instantiated in XAML and can set properties in XAML are KeyBinding and MouseBinding.

Examples

The following example shows how to create an InputBinding that passes a string as the CommandParameter.

Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4
See Also

Reference

Page view tracker