Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you get a submit button in the Windows Phone keyboard?

I want the white arrow to appear in my text input boxes so users have a way of forward other than tapping away from the keyboard or using the hardware Back button.

The search fields do this in the system UI. How do I?

Here's my code XAML:

<TextBox x:Name="InputBox" InputScope="Text" AcceptsReturn="True" TextChanged="InputBox_TextChanged"/>

CS:

void InputBox_TextChanged(object sender, KeyEventArgs e)
{
    // e does not have Key property for capturing enter - ??
}

One quick note, I have tried AcceptsReturn as False also.

like image 974
Subcreation Avatar asked Jul 07 '11 20:07

Subcreation


2 Answers

Also, I found that to get the white submit button that the search box has you can set the InputScope to "search":

<TextBox x:Name="InputBox" InputScope="Search" AcceptsReturn="False" KeyUp="InputBox_KeyUp"/>

I still haven't figured out if this has any unintended side-effects.

For good measure here is the code to dismiss the keyboard in the KeyUp event:

void InputBox_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
{
      if (e.Key == Key.Enter)
      {
           this.Focus();
      }
}
like image 175
Subcreation Avatar answered Oct 21 '22 06:10

Subcreation


Instead of handling the TextChanged method, handle the KeyUp method of the Textbox:

private void InputBox_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
{
      if (e.Key == Key.Enter)
      {
           //enter has been pressed
      }
}
like image 20
keyboardP Avatar answered Oct 21 '22 06:10

keyboardP