WPF Always on Top不起作用

时间:2016-07-07 03:30:59

标签: c# wpf window fullscreen topmost

我正在创建一个具有WPF前端的安装程序。当我从我的代码启动先决条件安装时,安装程​​序失去了焦点。结果显示任务栏。我不希望在UI运行时的任何阶段显示任务栏。我试图在窗口激活和停用事件中添加钩子,但它们也不起作用。以下是我的代码。请指教。

<Window x:Class="CustomBA.MainView"
    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:resources="clr-namespace:KubeCustomBA.Resources"
    mc:Ignorable="d"
    Title="Installer" Activated="window_Activated" Deactivated="Window_Deactivated" Width="1431" MinWidth="400" Height="588.9" MinHeight="300" ResizeMode="NoResize" WindowStyle="None" WindowState="Maximized" ShowInTaskbar="False" Topmost="False" WindowStartupLocation="CenterOwner" Background="#FF222222">

 void window_Activated(object sender, EventArgs e)
    {
        this.Width = System.Windows.SystemParameters.PrimaryScreenWidth;
        this.Height = System.Windows.SystemParameters.PrimaryScreenHeight;
        this.Topmost = true;
        this.Top = 0;
        this.Left = 0;
    }

    private void Window_Deactivated(object sender, EventArgs e)
    {
        this.Topmost = true;
        this.Activate();
    }

0 个答案:

没有答案