我有一个基本的登录页面,
<TextBox x:Name="UsernameInput" HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding Username, Mode=TwoWay}" VerticalAlignment="Center" Grid.Row="0" Grid.Column="2" Width="400" />
<PasswordBox HorizontalAlignment="Left" VerticalAlignment="Center" Password="{Binding Password, Mode=TwoWay}" Grid.Row="1" Grid.Column="2" Width="400"/>
<TextBlock HorizontalAlignment="Right" TextWrapping="Wrap" Text="Username: " VerticalAlignment="Center" Margin="0,0,0,15" Grid.Row="0" Grid.Column="0" Style="{StaticResource SubheaderTextStyle}"/>
<TextBlock HorizontalAlignment="Right" TextWrapping="Wrap" Text="Password: " VerticalAlignment="Center" Margin="0,0,0,15" Grid.Row="1" Grid.Column="0" Style="{StaticResource SubheaderTextStyle}"/>
<Button Content="Login" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="2" Grid.Column="2" Height="50" Width="300" Command="{Binding LoginCommand}"/>
如果用户从密码字段中按 Enter 键,我如何模拟按下的“登录”按钮?
谢谢!