Επεξεργασία

Κοινή χρήση μέσω


CanExecuteRoutedEventArgs.Parameter Property

Definition

Gets the command specific data.

public:
 property System::Object ^ Parameter { System::Object ^ get(); };
public object Parameter { get; }
member this.Parameter : obj
Public ReadOnly Property Parameter As Object

Property Value

The command data. The default value is null.

Examples

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 customCommand and 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"/>

Remarks

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.

Applies to

See also