CanExecuteRoutedEventArgs.Parameter Property

Gets the command specific data.

Namespace:  System.Windows.Input
Assembly:  PresentationCore (in PresentationCore.dll)

public Object Parameter { get; }
Members of this class are either not typically used in XAML, or cannot be used in XAML.

Property Value

Type: System.Object
The command data. The default value is null.

The command parameter is used to pass specific information to the command when it is executed. The type of the data is defined by the command.

Parameter can be null. Many commands do not process or expect command parameters.

The following example shows up to use a Button as the command source for a custom command. The Command property of the Button is set to the custom RoutedCommand called customComandand the CommandParameter is used to pass the value of the Value property of a Slider control. This is accomplishment by using databinding to bind the CommandParameter to the Value property. The converter in the binding expression is a custom IValueConverter which converts Value into an Int32 before binding it to the CommandParameter. For the complete source code for this sample, see Disable Command Source via Dispatcher Timer Sample.

<!-- The Command Source for the custom command-->
<!-- Passes Slider.Value as the CommandParameter-->
<Button Command="{x:Static custom:Window1.customCommand}" 
        Content="Command"
        CommandParameter="{Binding ElementName=secondSlider,
                            Path=Value,
                            Converter={StaticResource ValueConverterResource}}" 
        Margin="10"/>

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, 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.

.NET Framework

Supported in: 3.5, 3.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft