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.
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 .
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.
We found we have code like this.
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
.