Hide MainWindow (AgentDesktop)

Jun 2, 2010 at 5:12 AM

Hello

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 ?

Thanks

Jun 2, 2010 at 8: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..
http://msdn.microsoft.com/en-us/library/system.windows.window.hide.aspx

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 9: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 12: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..

MattB.

Jun 4, 2010 at 4: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 12: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
    {
        [System.STAThreadAttribute()]
        public static void Main()
        {
            //AifWpfShellBase desktop = null;
            //desktop = new AifWpfShellBase();
            //desktop.StartApplication(); // Boot Desktop.

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