microsoft-ui-xaml: Mouse right-click in TextBox crashes the application

Describe the bug Mouse right-click in TextBox crashes the application.

Steps to reproduce the bug

  • Create new WinUI 3 in Desktop project.
  • Add a TextBox to MainWindow.xaml
    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
        <Button x:Name="myButton" Click="myButton_Click">Click Me</Button>
        <TextBox/>
    </StackPanel>
  • Run the application
  • Right-click with the mouse pointer inside the TextBox

Expected behavior

Application doesn’t crash.

Screenshots

Version Info

NuGet package version:

WinUI 3 - Project Reunion 0.5: 0.5.0

Windows app type:

UWP Win32
Yes
Windows 10 version Saw the problem?
Insider Build (xxxxx)
October 2020 Update (19042) Yes
May 2020 Update (19041)
November 2019 Update (18363)
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop Yes
Xbox
Surface Hub
IoT

Additional context

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 30 (10 by maintainers)

Most upvoted comments

The exception is not thrown when a context menu is provided. As a workaround it can be defined and immediately closed when opening.

<TextBox>
    <TextBox.ContextFlyout>
        <Flyout Opening="OnFlyoutOpening"/>
    </TextBox.ContextFlyout>
</TextBox>

private void OnFlyoutOpening(object sender, object _)
{
    if(sender is Flyout f)
    {
        f.Hide();
    }
}

This is still an issue with the released version. I’m using the latest released windows app sdk and build tools that I could get working.

image

The only difference is the textbox needs to have text in it; it no longer repros when it starts empty.