FabrizioCaldarelli
1/11/2016 - 5:42 PM

Close keyboard when clicking on return key of textbox

Close keyboard when clicking on return key of textbox

// In Page class
public sealed partial class CustomPage : Page
{
  public CustomPage()
  {
    this.InitializeComponent();
  
    //...
  
    // This will give input focus capability to page
    this.IsTabStop = true;
  
  }
  
  private void textbox1_KeyUp(object sender, KeyRoutedEventArgs e)
  {
      if (e.Key == VirtualKey.Enter)
      {
          // This will move focus from textbox to the page
          this.Focus(FocusState.Programmatic);
      }
  }
  ...
  ...
  ...
}