Microsoft.Toolkit.Win32 icon indicating copy to clipboard operation
Microsoft.Toolkit.Win32 copied to clipboard

The Home/End button press doesn't propagates to a UWP RichEditBox inside of a WPF ScrollViewer

Open atiyka opened this issue 4 years ago • 57 comments

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:

  1. Create a WPF window with a ScrollViewer
  2. Place inside the ScrollViewer a custom UWP control (another project in the solution), which should contain a RichEditBox
  3. Write something into the RichEditBox
  4. 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)

atiyka avatar Jan 26 '21 11:01 atiyka

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 🙌

ghost avatar Jan 26 '21 11:01 ghost

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.

ghost avatar Feb 10 '21 14:02 ghost

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.

ghost avatar Feb 25 '21 14:02 ghost

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.

ghost avatar Mar 12 '21 14:03 ghost

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.

ghost avatar Mar 27 '21 17:03 ghost

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.

ghost avatar Apr 11 '21 20:04 ghost

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.

ghost avatar Apr 26 '21 23:04 ghost

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.

ghost avatar May 11 '21 23:05 ghost

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.

ghost avatar May 27 '21 02:05 ghost

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.

ghost avatar Jun 11 '21 05:06 ghost

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.

ghost avatar Jun 26 '21 08:06 ghost

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.

ghost avatar Jul 11 '21 08:07 ghost

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.

ghost avatar Nov 03 '21 02:11 ghost

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.

ghost avatar Nov 18 '21 05:11 ghost

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.

ghost avatar Dec 03 '21 08:12 ghost

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.

ghost avatar Dec 18 '21 11:12 ghost

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.

ghost avatar Jan 02 '22 14:01 ghost

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.

ghost avatar Jan 17 '22 14:01 ghost

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.

ghost avatar Feb 01 '22 14:02 ghost

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.

ghost avatar Feb 16 '22 17:02 ghost

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.

ghost avatar Mar 03 '22 17:03 ghost

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.

ghost avatar Mar 18 '22 20:03 ghost

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.

ghost avatar Apr 02 '22 20:04 ghost

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.

ghost avatar Apr 17 '22 23:04 ghost

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.

ghost avatar May 03 '22 02:05 ghost

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.

ghost avatar May 18 '22 05:05 ghost

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.

ghost avatar Jun 02 '22 08:06 ghost

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.

ghost avatar Jun 17 '22 08:06 ghost

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.

ghost avatar Jul 02 '22 11:07 ghost

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.

ghost avatar Jul 17 '22 14:07 ghost