I want to add application in System Tray when user minimize or close the form. I have done it for the Minimize case. Can anyone tell me that how i can keep my app running and ad
You need not use OnStateChanged(). Instead, use the PreviewClosed event.
OnStateChanged()
PreviewClosed
public MainWindow() { ... PreviewClosed += OnPreviewClosed; } private void OnPreviewClosed(object sender, WindowPreviewClosedEventArgs e) { m_savedState = WindowState; Hide(); e.Cancel = true; }