CanExecuteRoutedEventArgs.Parameter Property

 

Gets the command specific data.

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

public object Parameter { get; }

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.

<!-- 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"/>

.NET Framework
Available since 3.0
Return to top
Show: