<TextBox Text="{Binding InputText, UpdateSourceTrigger=PropertyChanged}">
<TextBox.InputBindings>
<KeyBinding Gesture="Enter" Command="{Binding EnterText}" />
</TextBox.InputBindings>
</TextBox>
TextBox.InputBindings で Input 操作を取得する
KeyBinding で Enter を Bind して ICommand を実行する
注意点は
UpdateSourceTrigger = PropertyChanged
で、Text プロパティのバインドを PropertyChanged としておくこと、既定は LostFocus なので Enter 操作時に Text に Bind した要素が更新されない。
0 件のコメント:
コメントを投稿