Reputation: 1713
We have a strange behaviour on with our WPF application in Windows 10 (update 1803 - Microsoft Surface Go).
Inside the application I have a Tabcontrol and it has its ItemsSource bound in codebehind to a list of objects(based on a usercontrol).
Whenever I press inside a textbox, the windows 10 keyboard appears and disappears immediately. If I click in the textbox again, the keyboard appears correctly. When I press in another textbox, the same happens again (keyboard appears/dissapears and I have to press again in the same textbox).
In other parts of the application this is NOT happening.
Strangely enough, when I just got the tablet, I would have sworn this problem did NOT happen. Since then, windows has updated.
I suspect this has to do with one of the windows updates because the same application works fine on other tablets with windows 10 of another brand (one of these other tablets I am sure they have a windows 10 LTSB version from 2016).
I have tried to remove as many updates as I can But cannot remove the 1803 cumulative update.
The .Net version I was using is .Net 4.0 and I have tried to update to 4.7.2 without success. As advised in this thread : C# WPF Windows 10 (1803) TouchKeyboard unreliable Issue (Prism ClickOnce)
I see that another person complains they have similar issues only after a specific windows 10 update. https://social.msdn.microsoft.com/Forums/en-US/b9efb4eb-e0a9-4bf0-9985-57a673c42f79/wpf-application-windows-10-touch-keyboard-flickering-issue?forum=wpf
I have tried to switch to tablet mode and to desktop mode. In both the same behaviour occurs. So, now I have defaulted to desktop mode with a "control panel"-setting where the keyboard appears if no physical keyboard is attached.
The only workaround That I have found is the following:
Put the tabcontrol inside a Grid and gridrow and Create a second GridRow (height=0) with a textbox inside (The new Textbox MUST be outside the tabcontrol). When one of the tabs is pressed, put the focus on the newly created textbox.
Keyboard.Focus(focusbox);
When I do this, the keyboard does not dissapear the first time I press a textbox inside the tabcontrol.
Upvotes: 3
Views: 1083
Reputation: 132
Inherit your TabControl and override the OnCreateAutomationPeer:
protected override AutomationPeer OnCreateAutomationPeer()
{
return new FrameworkElementAutomationPeer(this);
}
For some reason when I keep it to the default TabControlAutomationPeer, I have the same issue where the automatically opened touch keyboard (the TabTip.exe) closes immediately after pressing a textbox inside any of the tabs of the TabControl. If I change it to FrameworkElementAutomationPeer it works perfectly.
However, I'm not completely sure what the downside of this solution is. Whether there are any negative side effects.
Another solution might be to set registry key HKEY_CURRENT_USER\Software\Microsoft\TabletTip\1.7\DisableNewKeyboardExperience
to 1
, but that changes the appearance of the virtual keyboard to an older version, and the keyboard stays on screen after pressing another control.
Upvotes: 0