Skip to content

Multiple levels of menu items of DropDownButton behaves not well #1087

@orrindeng

Description

@orrindeng

Hello guys,

Originally, I met an issue that clicking the menu item will close the sub menu. And later I found a bug if there are a more than two levels of sub menu. The third sub menu will show when mouse button down and close when mouse button up.
image

We found we have code like this.

    protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
    {
        if (e.ClickCount == 1)
        {
            if (this.IsSplited)
            {
                if (this.GetTemplateChild("PART_ButtonBorder") is Border buttonBorder
                    && PopupService.IsMousePhysicallyOver(buttonBorder))
                {
                    this.OnClick();
                }
            }
            else if (this.HasItems)
            {
                this.IsSubmenuOpen = !this.IsSubmenuOpen;
            }
        }

        base.OnMouseLeftButtonUp(e);
    }

I looked into the dotnet WPF source code. MenuItem
And found that the base WPF MenuItem will show the sub menu when mouse down. But we will close it when mouse up with this.IsSubmenuOpen = !this.IsSubmenuOpen .

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions