Reputation: 59
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#?
Upvotes: 0
Views: 974
Reputation: 101742
Set Button.IsDefault
property to true then just handle the button click event.Pressing ENTER
will trigger your default button's click event after you set IsDefault
true..
Upvotes: 2