How to hide the functional keyboard of Windows Phone 8.1?

I want to hide the soft keyboard when the Enter key is pressed, but no solutions work for me correctly. (Windows Phone 8.1 Universal App)

This just doesn't work:

if (e.Key == VirtualKey.Enter) { textBox.IsEnabled = false; textBox.IsEnabled = true; } 

A method like this:

 private void LoseFocus(object sender) { var control = sender as Control; var isTabStop = control.IsTabStop; control.IsEnabled = false; control.IsTabStop = false; control.IsEnabled = true; control.IsTabStop = isTabStop; } 

only works partially. This only hides the keyboard when I use the text box for the first time. The second time the keyboard appears again.

+6
source share
3 answers

I just did something like this and it worked:

 private async void makeRequest(string title, int page) { myTextBox.IsEnabled = false; myTextBox.IsTabStop = false; // here is my httprequest and changing itemssource of listview myTextBox.IsEnabled = true; myTextBox.IsTabStop = true; } 
+2
source

There is direct API support for hiding and displaying InputPane. You do not need to try to fake the system.

Windows.UI.ViewManagement.InputPane methods are available. TryShow and TryHide . on Windows Phone 8.1.

Another option is to move the focus to a more appropriate control when the user presses Enter.

+17
source

This is the complete code to hide the keyboard when the user presses the enter key

  private void TextBox_KeyUp(object sender, KeyRoutedEventArgs e) { if(e.Key==Windows.System.VirtualKey.Enter) { Windows.UI.ViewManagement.InputPane.GetForCurrentView().TryHide(); } } 
+9
source

Source: https://habr.com/ru/post/977553/


All Articles