New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minimize to tray and Context Menu support on Tray Icon Windows MacOS #351
Comments
Finally I got this working: builder.ConfigureLifecycleEvents(lifecycle =>
{
lifecycle.AddWindows(lifecycleBuilder => lifecycleBuilder.OnWindowCreated(window =>
{
window.ExtendsContentIntoTitleBar = true;
var handle = WinRT.Interop.WindowNative.GetWindowHandle(window);
var id = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(handle);
var appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(id);
appWindow.Closing += async (s, e) =>
{
e.Cancel = true;
var result = await Application.Current?.MainPage?.DisplayAlert(
"App close",
"Do you really want to quit?",
"Close",
"Minimize to system tray")!;
if (result)
{
Application.Current?.Quit();
}
WindowExtensions.MinimizeToTray();
};
}));
}); |
And for MacOS? I've been looking for an implementation option for a long time, unfortunately I can't find any information and I'm dreaming of examples like the one for Windows. I'm starting to think that I'll have to wait until MAUI supports MacOS and not just the stripped-down Mac Catalyst version like it currently does. |
Have you tried this? I don't know about MacOS, but it seems to be supporting it as well. It may need some custom code, but in general has necessary functions. |
This was actually a very useful hint :) Thank you! @vadimffe |
It would be great if you could extend your example for WeatherTwentyOne to support:
Windows MacOS
https://github.com/dotnet/maui-samples/tree/main/7.0/Apps/WeatherTwentyOne/src/WeatherTwentyOne/Platforms/Windows
The text was updated successfully, but these errors were encountered: