KeyBinding-使用技巧

TextBox

1
2
3
4
5
6
7
8
<TextBox Text="{Binding LoginModel.UserNameUpdateSourceTrigger=PropertyChanged}" 
FontSize="16" Foreground="#555" Template="{UserNameTextBoxTemplate}"
Name="txtUserName">
<TextBox.InputBindings>
<KeyBinding Key="Enter" Command="{Binding LoginCommand}"
CommandParameter="{Binding ElementName=window}"/>
</TextBox.InputBindings>
</TextBox>