Hide MainWindow (AgentDesktop)

Jun 2, 2010 at 6:12 AM


I want to hide MainWindow on minimize, but when I call Hide() method, except hiding, my application was closed.

Why ? How can I only hide MainWindow ?


Jun 2, 2010 at 9:53 AM

Meaning, you want to Hide the app off the TaskBar on Minimize ?
Are you getting a close event?

Also here is the relevant MSDN Article on WPF hide..

Also if you do Hide the window,  How do you get it back ? 
What is the scenario your trying to enable?

- MattB.

Jun 2, 2010 at 10:05 AM

Yes I want to Hide the app on minimize, and call Hide method in Window_SizeChanged event. But I also tried to call this method from different places but get the same result.

I create notifyIcon. When user clicks it I set WindowState to FullScreen and bring main window to front.

Jun 3, 2010 at 1:01 PM

Hrm… interesting..
I have done this with the winform based desktop and it works.

Let me set this up in a dev env and give it a go, it may be a quirk of WPF..


Jun 4, 2010 at 5:27 AM

Ok :)
I tried it in winforms, even created separate WPF project and tried to change ShutDownMode, but it works.
I think something is wrong in AgentDesktop project, but can not understand what.


Jun 14, 2010 at 1:20 PM

I have found the main problem :)

Agent Desktop initialization was done via this pice of code

                desktop = new AifWpfShellBase<MainWindow>();
                desktop.StartApplication(); // Boot Desktop.

Here MainWindow was shown as Dialog. I tried to create separate project and do the same

  class Program
        public static void Main()
            //AifWpfShellBase desktop = null;
            //desktop = new AifWpfShellBase();
            //desktop.StartApplication(); // Boot Desktop.

            Window1 w = new Window1();
And get the same result: form was closed, after hiding.