Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

.net

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();
like image 476
Mohammad Abu Subha Avatar asked Jul 30 '18 14:07

Mohammad Abu Subha


People also ask

How do I hide the form on my taskbar?

To prevent your form from appearing in the taskbar, set its ShowInTaskbar property to False.

How do I close a window in WPF?

Pressing ALT + F4 . Pressing the Close button. Pressing ESC when a button has the IsCancel property set to true on a modal window.

How do I display another window in WPF?

You will need to create an instance of a new window like so. var window2 = new Window2(); Once you have the instance you can use the Show() or ShowDialog() method depending on what you want to do. var result = window2.

How do I set the WPF window to the center of the screen?

To open a new window and have it centred on the screen, set the WindowStartupLocation property to CenterScreen. You can do this using the XAML or in code before the window is displayed. Run the program and click the button to see the result.


1 Answers

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.

like image 176
Alex Avatar answered Sep 30 '22 18:09

Alex