Reputation: 21
I am developing UWP application for windows 10 OS. I need to show touch screen keyboard when user click on a text box.
Following are the requirements.
1.Windows 10 OS
2.Tablet mode off
3.Hardware Keyboard is attached.
I have go through the Microsoft sample https://github.com/microsoft/Windows-universal-samples/tree/master/Samples/TouchKeyboard. But could not find a solution.
I have enabled “show the touch keyboard when not in tablet mode and there’s no keyboard attached” keyboard setting. As it says it only works when there is no hardware keyboard attached.
But I need to show the touch screen keyboard while there is a hardware keyboard as well
I tried to use InputPane as following code sample:
MainPage.xaml
< TextBox x:Name="text1" Width="300" Height="50" ></TextBox>
MainPage.xaml.cs
{
this.InitializeComponent();
text1.AddHandler(TappedEvent, new TappedEventHandler(text1_Tapped), true);
}
private void text1_Tapped(object sender, TappedRoutedEventArgs e)
{
InputPane pane = InputPane.GetForCurrentView();
pane.TryShow();
}
That also not showing touch screen keyboard when hardware keyboard is attached .
Please guide me to solve this requirement.
Upvotes: 2
Views: 1727
Reputation: 111
I was able to Show/Hide the On Screen Keyboard in Desktop Mode by using CoreInputView.GetForCurrentView().TryShow(CoreInputViewKind.Keyboard).
Code Sample:
.xaml:
<TextBox GotFocus="TextBox_OnGotFocus" LostFocus="TextBox_OnLostFocus" InputScope="Number"/>
.xaml.cs:
private void TextBox_OnGotFocus(object _, RoutedEventArgs __)
{
CoreInputView.GetForCurrentView().TryShow(CoreInputViewKind.Keyboard);
}
private void TextBox_OnLostFocus(object _, RoutedEventArgs __)
{
CoreInputView.GetForCurrentView().TryHide();
}
Additionally, you can control the keyboard type by setting the InputScope with values like: Number, NumericPin, Text, or others: https://learn.microsoft.com/en-us/uwp/api/Windows.UI.Xaml.Input.InputScopeNameValue
Upvotes: 2
Reputation: 32785
Is there a way to show Touch Screen Keyboard in UWP app when there is a Hardware Keyboard- Windows 10
Derive from this case, we could not launch Touch Screen Keyboard within UWP desktop model. But we could launch wpf app and then call osk.exe
indirectly.
For integrating wpf app into UWP, we could refer this tutorial. And communicate with wpf client by UWP AppService
.
We could send message to tell wpf client to launch osk.exe
when the TextBox focused from UWP Client
.
Upvotes: 0