Microsoft.Toolkit.Win32
Microsoft.Toolkit.Win32 copied to clipboard
The Home/End button press doesn't propagates to a UWP RichEditBox inside of a WPF ScrollViewer
Describe the bug
In a WPF
application (targeting .NET core 3.1
) on one of the windows, I have a ScrollViewer
and inside the ScrollViewer (among other elements) I placed a custom UWP control, which contains a RichEditBox
. I added this custom UWP control via XamlHosts
:
<Window xmlns:xaml="clr-namespace:Microsoft.Toolkit.Wpf.UI.XamlHost;assembly=Microsoft.Toolkit.Wpf.UI.XamlHost">
...
<ScrollViewer>
<Grid>
...
<xaml:WindowsXamlHost InitialTypeName="UWPControls.MyRichBox" x:Name="UwpRichEditBox"/>
</Grid>
</ScrollViewer>
<Window>
The UWP styled RichEditBox shows up in the WPF app, I can type text, move the caret with the arrow buttons, but some of the key events are not working. For example I can't use the Home/End buttons to go to the beginning or to the ending of a line in the RichEditBox.
The issue is that, the ScrollViewer in the WPF app catches these button presses (Home/End/Ctrl+Right-Left) and it's not propagated towards the Xaml Island RichEditBox control. I know this, because if I remove the ScrollViewer, the issue disappears.
I can catch the keyboard events in WPF, but in the XamlIsland UWP control the events are not fired at all when I press the Home or End buttons (nor the KeyDownEvent, neither the PreviewKeyDownEvent). For other keys they are fired.
I tried to raise a keyboard event in the UWP control with InputInjector
, but as it bubbled up towards the ScrollViewer in WPF, it stopped the event and the RichEditBox didn't handled. But why? Since the RichEditBox is inside of the ScrollViewer and should handle first.
Steps to Reproduce
Steps to reproduce the behavior:
- Create a WPF window with a ScrollViewer
- Place inside the ScrollViewer a custom UWP control (another project in the solution), which should contain a RichEditBox
- Write something into the RichEditBox
- Press the Home button. The cursor doesn't go to the first character of the line
Expected behavior
The Home/End buttons should be consumed first by the RichEditBox inside the ScrollViewer.
Environment
NuGet Package(s):
Microsoft.Toolkit.Wpf.UI.XamlHost - version 6.1.2
Project .NET Version:
- [x] .NET Core 3.1
Windows 10 Build Number:
- [x] version 2004, os build 9041.746
App min and target version:
- [x] May 2019 Update (18362)
Device form factor:
- [x] Desktop
Visual Studio
- [x] 2019 Community (version: 16.7.7)
Hello atiyka, thank you for opening an issue with us!
I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.
This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.