简体   繁体   English

如何从任务栏(WPF)隐藏打开的子窗口?

[英]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?当我显示和隐藏子窗口时,如何隐藏任务栏中打开的子窗口,即使隐藏子窗口隐藏窗口仍然出现在任务栏 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();

There should be a ShowInTaskbar property for the window.窗口应该有一个ShowInTaskbar属性。

If your window is defined in XAML, you can set the property deliberately as shown below:如果您的窗口是在 XAML 中定义的,您可以特意设置属性,如下所示:

<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.不过,为了将来参考,这是在 google 上查找的相当快速的解决方案 - 通常值得先搜索答案,因为它有时可以是解决问题的更快方法。

in this case, I reworded your issue to "hide task bar icon for window in wpf".在这种情况下,我将您的问题改写为“在 wpf 中隐藏窗口的任务栏图标”。 The child window part wasn't really needed in the search, as all windows in WPF are basically the same.搜索中并不真正需要子窗口部分,因为 WPF 中的所有窗口基本相同。

I hope that's of some help.我希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM