There are several issues here. First of all, if the ShowInTaskbar property is set to false, an invisible window is created and set as the parent of the current window. This invisible window icon is displayed when switching between windows.
You can catch this window with Interop and set it like this:
private void Window_Loaded(object sender, RoutedEventArgs e) { SetParentIcon(); } private void SetParentIcon() { WindowInteropHelper ih = new WindowInteropHelper(this); if(this.Owner == null && ih.Owner != IntPtr.Zero) {
Other issues you thought about would be:
- Find out what happens when the ShowInTaskbar property changes at runtime;
- Remove the icon from your window, not from the file;
Stanislav Kniazev
source share