You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WPF should not show the touch keyboard for read-only fields #1133
Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
Problem description:
WPF uses direct calls to InputPane.TryShow via TipTsfHelper when the focused control implements the text UIA pattern, UIA is already loaded, and if the OS is >= RS1.
This means that even if the exposed TextPattern is marked read-only, WPF will request the KB to show.
What is actually needed is a finer grained set of conditions.
Don't call TryShow if the TextPattern implementation declares it is read-only
Don't call TryShow if the focus tracking for the touch KB does not use UIA, but uses TSF (RS3+, but this needs confirmation).
This can be mitigated in later OSes (RS3+) by setting the AppContext flag DisableImplicitTouchKeyboardInvocation. This stops WPF from calling InputPane.TryShow but the KB focus tracking and invocation will still work.
changed the title [-]WPF should not show the keyboard for read-only fields[/-][+]WPF should not show the touch keyboard for read-only fields[/+]on Jul 1, 2019
Here's what I've tried so far to workaround this issue:
Setting TextBox's Focusable property to false if it's read only. This does solve the problem but creates other problems, e.g., user cannot select text, which is unacceptable in my case.
Creating a new class that derives from TextBox and overriding OnCreateAutomationPeer like following:
The problem with this approach is that the user can change whether the textbox is read-only or not in my app, but it doesn't seem like we can change the supplied AutomationPeer after OnCreateAutomationPeer is raised (I tried calling FrameworkElementAutomationPeer.FromElement(MyTextBoxInstance)?.InvalidatePeer() and FrameworkElementAutomationPeer.CreatePeerForElement(MyTextBoxInstance) to no avail) so whether or not touch keyboard shows up won't adapt to further changes to the IsReadOnly property of MyTextBox.
No, that's not the desired behavior for my app. For the purposes of my app, touch keyboard should never show up unless TextBox's IsReadOnly property is set to false.
Activity
[-]WPF should not show the keyboard for read-only fields[/-][+]WPF should not show the touch keyboard for read-only fields[/+]rampaa commentedon Aug 15, 2023
Any progress on this?
lindexi commentedon Aug 17, 2023
@rampaa It seems that the problem is not easy to fix
rampaa commentedon Aug 17, 2023
Here's what I've tried so far to workaround this issue:
Setting TextBox's
Focusableproperty tofalseif it's read only. This does solve the problem but creates other problems, e.g., user cannot select text, which is unacceptable in my case.Creating a new class that derives from TextBox and overriding
OnCreateAutomationPeerlike following:The problem with this approach is that the user can change whether the textbox is read-only or not in my app, but it doesn't seem like we can change the supplied
AutomationPeerafterOnCreateAutomationPeeris raised (I tried callingFrameworkElementAutomationPeer.FromElement(MyTextBoxInstance)?.InvalidatePeer()andFrameworkElementAutomationPeer.CreatePeerForElement(MyTextBoxInstance)to no avail) so whether or not touch keyboard shows up won't adapt to further changes to theIsReadOnlyproperty of MyTextBox.miloush commentedon Aug 17, 2023
If you expect users to select (and copy) text, then you should have touch keyboard appear so that they can perform these tasks using keyboard.
rampaa commentedon Aug 17, 2023
No, that's not the desired behavior for my app. For the purposes of my app, touch keyboard should never show up unless TextBox's
IsReadOnlyproperty is set to false.rampaa commentedon Jun 19, 2024
Will this be fixed in the future? Its milestone was set to 7.0.0 but obviously it isn't fixed even in 8.0.x.
Set DisableImplicitTouchKeyboardInvocation switch to true for solving d…