CanExecuteRoutedEventArgs.Parameter 屬性

定義

取得命令特有的資料。

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

屬性值

命令資料。 預設值是 null

範例

下列範例顯示使用 Button 做為自定義命令的命令來源。 CommandButton 屬性會設定為自定義RoutedCommand的呼叫customCommandCommandParameter並使用 傳遞 Value 控件的 Slider 屬性值。 這是藉由使用數據系結來系結 CommandParameter 至 屬性來 Value 達成。 系結運算式中的轉換器是自定義的 ,IValueConverter它會在Int32將它系結至 CommandParameter之前轉換成 Value

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

備註

命令參數是用來在執行命令時將特定資訊傳遞至命令。 數據的類型是由 命令所定義。

Parameter 可以是 null。 許多命令不會處理或預期命令參數。

適用於

另請參閱