Wpf ShowInTaskBar设置为false,窗口在任务栏中仍然可见

Wpf ShowInTaskBar设置为false,窗口在任务栏中仍然可见,wpf,Wpf,如果我将ShowInTaskbar设置为false,则该窗口在任务栏中仍然可见(Windows 10)。这不是我想要的 xaml: <Window x:Class="mycontrol.TextureProperties" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xa

如果我将ShowInTaskbar设置为false,则该窗口在任务栏中仍然可见(Windows 10)。这不是我想要的

xaml:

<Window x:Class="mycontrol.TextureProperties"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:local="clr-namespace:foo"
         mc:Ignorable="d" 
         Title="Textures Dialog"
         d:DesignHeight="300" d:DesignWidth="300"
         Height="300"   Width="300" ResizeMode="NoResize" ShowInTaskbar="False" >
<Grid Width="300" Height="300">
    <Label Content="Textures Display here" />
</Grid>
</Window>
以及我如何实例化它:

textures = new TextureProperties();
textures.WindowStartupLocation = WindowStartupLocation.Manual;
Debug.Assert(textures.ShowInTaskbar == false);
textures.Owner = this;
textures.Show();
其他:

  • .NET 4.6.2
  • 在Windows10上运行
  • 我试过:

  • 调用textures.ShowDialog(),这也不起作用
  • 在stackoverflow上搜索类似问题。我找到了一个有点关联的。他们想在任务栏上显示窗口,而不是像我想的那样隐藏它。尽管我尝试了答案(设置所有者属性),但这对我没有帮助
  • 请注意,我的断言
    ShowInTaskbar
    是错误的,通过了。断言不会在运行时触发
  • 所有不同的WindowsStyle选项,这仍然没有帮助
  • [编辑]

    在进一步测试之后,我发现在调用windows
    Show()
    方法之后,它再次将ShowInTaskbar设置为true。不太好的WPF

    在上面的代码中,断言在运行时失败。那为什么要在我背后设置呢?

    你试过
    #if DEBUG//…//#endif
    而不是
    DEBUG.Assert(…)

    还要检查您的调试配置-可能是因为版本1而失败:)

    textures = new TextureProperties();
    textures.WindowStartupLocation = WindowStartupLocation.Manual;
    Debug.Assert(textures.ShowInTaskbar == false);
    textures.Owner = this;
    textures.Show();
    
    textures.Show();
    Debug.Assert(textures.ShowInTaskbar == false);