-1

I want change behavior of standard close button of window. When user clicked on it then minimize to tray, not close window. How can I do this?

P.S Here is a small video example of this behavior on Slack application. I want do sameenter image description here.

Max951
  • 51
  • 4
  • The window of mac already have minimize button, you can set it on your own https://learn.microsoft.com/en-us/xamarin/mac/user-interface/window – Adrain Dec 03 '21 at 01:36
  • Yes, I know this. But I need minimize to tray on close button, like Slack app in macOS, you can install it and try click on close button and then app is not close - it minimized – Max951 Dec 03 '21 at 07:14
  • try disable the close button if you dont need it – Adrain Dec 06 '21 at 08:47
  • No, I need close button, but close button must minimize app to tray, not close it. I have updated description and record example with Slack app what I want to do. – Max951 Dec 06 '21 at 11:29

1 Answers1

0

Override the applicationShouldTerminateAfterLastWindowClosed method in appdelegate like:

public override bool ApplicationShouldTerminateAfterLastWindowClosed(NSApplication sender)
{
return false;
}
Adrain
  • 1,946
  • 1
  • 3
  • 7