监听enter事件触发
<TextBox.InputBindings>
<KeyBinding Key="Enter" Command="{Binding LoginCommand}"
CommandParameter="{Binding ElementName=window}"/>
</TextBox.InputBindings>
聚焦
<Grid Grid.Row="1" Margin="30,10" FocusManager.FocusedElement="{Binding ElementName=txtUserName}">
<TextBox Height="42" Text="{Binding LoginModel.UserName,UpdateSourceTrigger=PropertyChanged}"
FontSize="16" Foreground="#555" Template="{StaticResource UserNameTextBoxTemplate}"
Name="txtUserName">
<TextBox.InputBindings>
<KeyBinding Key="Enter" Command="{Binding LoginCommand}"
CommandParameter="{Binding ElementName=window}"/>
</TextBox.InputBindings>
</TextBox>
</Grid>