0
votes
<Window WindowStyle="None" WindowState="Minimized" ResizeMode="NoResize" 
        ShowInTaskbar="False">

When I minimize a WPF window with these settings for WindowStyle, WindowState, ResizeMode and ShowInTaskbar properites a ghost window looking like this:

Ghost Window

appears on the desktop...

When I change ShowInTaskbar property to "True" the ghost window is not displayed but I don't want the window to show in the taskbar so that is not a solution...

Did anyone ever run into this and is there a solution?

1
What are you tring to do?, create an invisible window? the problem is if you minimize your app and its not in the taskbar how are you going to access you app again?sa_ddam213
@sa_ddam213 Never heard of "Minimize to Tray"?Dean Kuga
You never mentioned that, I thought you wanted to make the window invisible,LOL, But Minimize to Tray is pretty simple.sa_ddam213
@sa_ddam213 Yes, it's simple, ShowInTaskbar="False" and WindowState="Minimized" but that gives me the ghost window... if you have a better solution please share...Dean Kuga
That won't minimise to tray, You have to setup a NotifyIcon, I updated answer with Minimise to tray examplesa_ddam213

1 Answers

1
votes

If you want to minimize to tray, try this

    public MainWindow()
    {
        InitializeComponent();
        System.Windows.Forms.NotifyIcon trayIcon = new System.Windows.Forms.NotifyIcon();
        trayIcon.Icon = new System.Drawing.Icon("myIcon.ico");
        trayIcon.Visible = true;
        trayIcon.Click += (s, e) =>
        {
            Show();
            WindowState = WindowState.Normal;
        };
    }

    protected override void OnStateChanged(EventArgs e)
    {
        if (WindowState == WindowState.Minimized)
        {
            Hide();
        }
        base.OnStateChanged(e);
    }