Mohammad Abu Subha
Mohammad Abu Subha

Reputation: 164

How can hide the opened child windows from taskbar (WPF)?

How can hide the opened child windows from taskbar when I am showing and hiding the child windows even when I hide the child window the hidden window still appear in the taskbar WPF?

Thanks in advance, Here is an Example how I show the dialogs:

AlignLocalAxisView alignLocalAxisView = Container.Resolve<AlignLocalAxisView>
    (new ParameterOverride("model", AttributesSelectedItems));
OpenedWindowView = alignLocalAxisView;
alignLocalAxisView.Show();

Upvotes: 12

Views: 11847

Answers (1)

Alex
Alex

Reputation: 1692

There should be a ShowInTaskbar property for the window.

If your window is defined in XAML, you can set the property deliberately as shown below:

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d"
    x:Class="MyApplication.MainWindow"
    Title="MainWindow" 
    Height="350" Width="425" 
    ShowInTaskbar="False">

You can also set this in your code behind:

    this.ShowInTaskbar = false;

This is also applciable to a window created in code behind when called by name.

    Window myNewWindow = new Window();

    //Set the property to keep the window hidden in the task bar
    myNewWindow.ShowInTaskbar = false;

    //Then, show the window
    myNewWindow.Show();

EDIT: Based on your example code, the following should work

    AlignLocalAxisView alignLocalAxisView = Container.Resolve<AlignLocalAxisView>(new ParameterOverride("model", AttributesSelectedItems));

    OpenedWindowView = alignLocalAxisView;

    //Assuming your view extends the Window class, the following will work
    alignLocalAxisView.ShowInTaskbar = false;

    alignLocalAxisView.Show();

Hopefully, this will be enough to sort the problem out.

For future reference though, this was a fairly quick solution to look up on google - its generally worth searching for an answer first as it can sometimes be a faster way to solve the problem.

in this case, I reworded your issue to "hide task bar icon for window in wpf". The child window part wasn't really needed in the search, as all windows in WPF are basically the same.

I hope that's of some help.

Upvotes: 28

Related Questions