0

現在、私のページは完全に機能しています。

以下のようなボタンとテキストボックスがあります。

<Button Command="{Binding [someViewModel].SomeCommand}" 
    CommandParameter="{Binding RelativeSource={RelativeSource Self}}" />
<TextBox Text="{Binding [someViewModel].userInput}"

そして以下に、次の定義がありますSomeCommand:</p>

public ICommand SomeCommand {get;set;}

SomeCommand = RelayCommand<FrameworkElement>
    .GetInterceptableInstance((Action<FrameworkElement>)this.someMethod)

そして、以下の定義someMethod:

private void someMethod(FrameworkElement control)
{
     MessageBox.Show(this.userInput);
}

基本的に、ユーザーがボタンをクリックすると、メッセージボックスが表示され、userInput が表示されます。問題はなく、完全に動作します。

someMethod今、ユーザーが Enter キーを押したときに呼び出そうとしていますTextBoxが、に提供する必要があるパラメーターがわかりませんsomeMethod

以下は、入力キーを検出する私の実装です。

private void DetectEnterKey(KeyEventArgs e)
{
    if(e.Key==Key.Return)
    {
        //this.someMethod() with what parameter?

    }
}
4

0 に答える 0