Skip to content

System.NullReferenceException in Avalonia.Controls.Utils.KeyboardHelper #99

Open
@scottdoingwork

Description

@scottdoingwork

Describe the bug

var keymap = TopLevel.GetTopLevel(target)!.PlatformSettings!.HotkeyConfiguration;
TopLevel.GetTopLevel(target) returns null, causing program crash.

System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=Avalonia.Controls.DataGrid
StackTrace:
at Avalonia.Controls.Utils.KeyboardHelper.GetPlatformCtrlOrCmdKeyModifier(Control target) in Avalonia.Controls.Utils\KeyboardHelper.cs:line 22
......
at Avalonia.Win32.WindowImpl in src\Windows\Avalonia.Win32\WindowImpl.AppWndProc.cs 769

To Reproduce

Put DataGrid in a popup. Pressing mouse left button on datagrid let popup close immediately.

Expected behavior

Program won't crash in this situation.

Avalonia version

11.0.11

OS

Windows

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions