Reputation: 2630
I have a button defined in XAML as follows:
<Button IsDefault="True" FontSize="12" Margin="312,16,155,3.6" Height="28" Name="SaveButton" Width="99" Click="SaveButton_Click">Save</Button>
In my SaveButton_Click
method, I received two arguments: the sender and the event.
Is it possible to determine whether or not the submit method was invoked because of a click on the button or because of hitting the Enter key?
Upvotes: 0
Views: 216
Reputation: 1235
Yes You can.
if (InputManager.Current.MostRecentInputDevice is KeyboardDevice)
MessageBox.Show("Enter key");
else
MessageBox.Show("Mouse click");
Upvotes: 2