Open vadimffe opened 1 year ago
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.
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.
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