Browse Source

Prevent showing trayMenu if the menu is empty.

pull/9620/head
zhouzj 4 years ago
parent
commit
915aff2eea
  1. 10
      src/Windows/Avalonia.Win32/TrayIconImpl.cs

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

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

Loading…
Cancel
Save