简体   繁体   中英

How to add enter key event on a button

I have a button in XAML here:

<Button Content="Login" x:Name="loginButton" Grid.Row="7" Grid.Column="3"
        Margin="200,30,0,0" Grid.RowSpan="2" Height="50" Width="150"
        VertialAlignment="Top" Click="loginButton_Click" ClickMode="Press"
        FontSize="24" FontFamily="Calibri" Style="{StaticResource AlbaabButtonStyle}">
</Button>

When user hits the enter key, he must be logged in to his account. How do I generate a press enter key event in c#?

Button.IsDefault属性设置为true然后只需处理按钮单击事件。在设置IsDefault true后,按ENTER将触发默认按钮的单击事件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM