【发布时间】:2019-06-18 08:53:05
【问题描述】:
我想从任务菜单 (Alt+Tab) 中隐藏一个包含 WindowStyle="None"、AllowTransparency="True" 和 ShowInTaskbar="False" 的 WPF 窗口。
我已经对此进行了研究,但所有结果似乎都是针对 WinForms 的,或者没有答案。以下是我已经研究过的一些来源:
- Same question on VS community WITHOUT an answer
- Same question on StackOverflow but for WinForms
- Same question but for WinForms on generic site
- This doesn't meet my requirements because I still want the WPF window to be visible, just not seen in the Alt+Tab menu
这是我的 XAML 代码:
<Window x:Class="DesktopInfo.MainWindow"
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"
xmlns:local="clr-namespace:DesktopInfo"
mc:Ignorable="d"
Title="MainWindow" SizeToContent="WidthAndHeight" WindowStyle="None" AllowsTransparency="True" Background="Transparent" ShowInTaskbar="False" Loaded="FormLoaded">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Text="Testing" Name="UsernameTextBlock" FontSize="20" FontWeight="Bold" Foreground="White"/>
<TextBlock Name="ComputernameTextBlock" Grid.Row="1" FontSize="20" FontWeight="Bold" Foreground="White"/>
</Grid>
</Window>
这是我的 C# 代码:
using System;
using System.Windows;
using System.Windows.Forms;
namespace DesktopInfo
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
///
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}
无论我尝试什么,我都无法让 WPF 表单不显示在 Alt+Tab 菜单中。非常感谢任何帮助:)
重复标志后更新 在查看了提供的链接(以及在提出这个问题之前查看过)之后,我想声明我实际上找到了answer here,并将发布我的完整代码作为这个问题的答案:)
【问题讨论】:
-
@John 谢谢你的链接,我会更新我的问题,为什么这不符合我的要求:)
-
@Andy 我真的看到了这个,看起来很有希望。但是,答案中的一些 cmets 表示它不再有效。看起来工作量很大,老实说,我不确定代码应该放在哪里。