閱讀英文版本

分享方式:


ExecutedRoutedEventArgs.Parameter 屬性

定義

重要

部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。

取得命令的資料參數。

C#
public object Parameter { get; }

屬性值

命令特有資料。 預設值是 null

範例

下列範例會 ExecutedRoutedEventHandler 建立自訂 RoutedCommand的 。 處理程式會使用目前的時間和Value透過 傳遞至處理程式ExecutedRoutedEventArgs.ParameterSlider 控制項屬性來更新 TextBox

C#
//  Executed Event Handler
//
//  Updates the output TextBox with the current seconds 
//  and the target second, which is passed through Args.Parameter.
private void CustomCommandExecuted(object sender, ExecutedRoutedEventArgs e)
{
    txtResults.Text = "Command Executed at " +
        DateTime.Now.Second + " seconds after the minute \n\n" +
        "The target second is set to " +
        e.Parameter;
}

備註

這個屬性代表特定命令所定義的泛型數據參數。

如果不需要此參數, null 可以傳遞。

一般而言, Parameter 會在執行命令時,用來將特定資訊傳遞至 命令。 數據類型是由 命令所定義。

適用於

產品 版本
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

另請參閱