Drastic.TrayWindow.Maui
1.0.9
dotnet add package Drastic.TrayWindow.Maui --version 1.0.9
NuGet\Install-Package Drastic.TrayWindow.Maui -Version 1.0.9
<PackageReference Include="Drastic.TrayWindow.Maui" Version="1.0.9" />
paket add Drastic.TrayWindow.Maui --version 1.0.9
#r "nuget: Drastic.TrayWindow.Maui, 1.0.9"
// Install Drastic.TrayWindow.Maui as a Cake Addin #addin nuget:?package=Drastic.TrayWindow.Maui&version=1.0.9 // Install Drastic.TrayWindow.Maui as a Cake Tool #tool nuget:?package=Drastic.TrayWindow.Maui&version=1.0.9
Drastic.TrayWindow.Maui
Drastic.TrayWindow.Maui is a helper library for Drastic.TrayWindow, letting you intergrate it into your existing MAUI application.
Drastic.TrayWindow.Maui supports Mac Catalyst and WinUI.
IMPORTANT
For this to work on Mac Catalyst, we are using Objective-C Selectors for directly accessing AppKit APIs from UIKit. These are private, and are frowd upon by Apple. You may have issues publishing apps using this library within the Mac App Store. While it should "work" it is best seen as experimental.
Setup
First, for Mac Catalyst, you need to set it up to allow for multiple windows. You MUST follow the documentation, including setting up the info.plist and SceneDelegate for MAUI. If you don't do this, you won't get full multi-window support and this won't work.
Once you do this, verify that multiple window support works for your project. Then, install this nuget.
In your AppDelegate.cs
, switch it to use MauiTrayUIApplicationDelegate
namespace Drastic.TrayWindow.Sample.Maui;
[Register("AppDelegate")]
public class AppDelegate : MauiTrayUIApplicationDelegate
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
Next, in your MauiProgram.cs
, add AddTrayWindowSupport
var builder = MauiApp.CreateBuilder();
builder
.AddTrayWindowSupport()
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
Now you can add a tray window. This can only happen after the Maui Context has been created, so only after your first Maui Window
has been created. Once you verify that has occured, you can then invoke the following helper:
var image = App.GetResourceFileContent("favicon.png");
Drastic.TrayWindow.Maui.MauiTrayWindow.Generate("Test", image!, new TrayWindowOptions(), new SamplePage());
Image
is an image Stream
, this could come from an existing MAUI image from your resources, or as a standalone file on your system.
Tips
- While you can use
Shell
inside of theTrayWindow
, you lose most of the functionality for page navigation and deep linking. - In general, use simple pages for best results. Trying to put your entire application inside of the tray is not ideal. Use discretion.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0-maccatalyst15.4 is compatible. net7.0-windows10.0.19041 is compatible. net8.0-maccatalyst was computed. net8.0-windows was computed. |
-
net7.0-maccatalyst15.4
- Drastic.Tray (>= 1.0.9)
- Drastic.TrayWindow (>= 1.0.9)
-
net7.0-windows10.0.19041
- Drastic.Tray (>= 1.0.9)
- Drastic.TrayWindow (>= 1.0.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.