Author Topic: WPF - How to submit the form when Enter key is pressed - IsDefault="True"  (Read 3897 times)


  • Administrator
  • Sr. Member
  • *****
  • Posts: 283
You need to have a button that applies the changes in the window. You can call this button as "Apply" or "Submit". You can implement this very easily.

Then all you need to do is, mapping the ENTER with the button. To do this, simply setting IsDefault="True" does the magic for you.

Here is the xaml code.

//Source Code Listing

<Button Width="65"  Height="22" IsDefault="True" Name="gui_submitbutton" Content="Submit"
Click="SubmitButton_Click" ToolTip="Accept the changes and submit the form"></Button>

Here is the event handler code in C#.

//Source Code Listing

public partial class MyWindow : Window

   private void SubmitButton_Click(object sender, RoutedEventArgs e)
      // code to accept the changes from the window / dialog



Disclaimer: This web site is for educational and informational purposes only. Click here to read the Disclaimer.
Content copyright 2010-2014. Kathiresan. All rights reserved.
This page is using SMF version 2.0.1