Skip to content

Commit

Permalink
Merge pull request #8604 from AvaloniaUI/feature/tray-icon-non-mandatory
Browse files Browse the repository at this point in the history
Don't throw exceptions for missing windowing platform since it's actually not mandatory for TrayIcon
  • Loading branch information
maxkatz6 authored Jul 27, 2022
2 parents 4be332a + 7315bc2 commit abc577f
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/Avalonia.Controls/Platform/PlatformManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,8 @@ public static void SetDesignerScalingFactor(double factor)
{
}

public static ITrayIconImpl? CreateTrayIcon()
{
var platform = AvaloniaLocator.Current.GetService<IWindowingPlatform>();

if (platform == null)
{
throw new Exception("Could not CreateTrayIcon(): IWindowingPlatform is not registered.");
}

return s_designerMode ? null : platform.CreateTrayIcon();
}
public static ITrayIconImpl? CreateTrayIcon() =>
s_designerMode ? null : AvaloniaLocator.Current.GetService<IWindowingPlatform>()?.CreateTrayIcon();


public static IWindowImpl CreateWindow()
Expand Down

0 comments on commit abc577f

Please sign in to comment.