Browse Source

Merge pull request #9620 from comesx4/fix-tray-menu-issue

bugfix: Prevent showing trayMenu if the menu is empty.
pull/9637/head
Dan Walmsley 4 years ago
committed by GitHub
parent
commit
9e41e223f8
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      src/Windows/Avalonia.Win32/TrayIconImpl.cs

9
src/Windows/Avalonia.Win32/TrayIconImpl.cs

@ -19,7 +19,6 @@ namespace Avalonia.Win32
public class TrayIconImpl : ITrayIconImpl public class TrayIconImpl : ITrayIconImpl
{ {
private static readonly IntPtr s_emptyIcon = new System.Drawing.Bitmap(32, 32).GetHicon(); private static readonly IntPtr s_emptyIcon = new System.Drawing.Bitmap(32, 32).GetHicon();
private readonly int _uniqueId; private readonly int _uniqueId;
private static int s_nextUniqueId; private static int s_nextUniqueId;
private bool _iconAdded; private bool _iconAdded;
@ -137,6 +136,12 @@ namespace Avalonia.Win32
private void OnRightClicked() private void OnRightClicked()
{ {
var menuItems = _exporter.GetMenu();
if (null == menuItems || menuItems.Count == 0)
{
return;
}
var _trayMenu = new TrayPopupRoot() var _trayMenu = new TrayPopupRoot()
{ {
SystemDecorations = SystemDecorations.None, SystemDecorations = SystemDecorations.None,
@ -145,7 +150,7 @@ namespace Avalonia.Win32
TransparencyLevelHint = WindowTransparencyLevel.Transparent, TransparencyLevelHint = WindowTransparencyLevel.Transparent,
Content = new TrayIconMenuFlyoutPresenter() Content = new TrayIconMenuFlyoutPresenter()
{ {
Items = _exporter.GetMenu() Items = menuItems
} }
}; };

Loading…
Cancel
Save