WPF:在 Win10 平板电脑模式下打开另一个应用程序

WPF: Open application on top of another in Win10 Tablet mode

我目前正在做一个个人 win10 wpf 项目,这是一个简单的工具,可以帮助我在我的 win10 平板电脑上使用其他程序。

因此,其中一项要求是该程序 应该 运行 处于非最大化模式,其他应用程序在其下方。 您可以在虚拟键盘程序、滴管、屏幕截图程序中找到这种行为的几个例子。它们 运行 在其他应用程序之上,您仍然可以看到其他应用程序仍在 运行ning 后面。

我的应用程序 运行 在桌面模式下运行良好,因为您可以 运行 多个 windows 同时相互重叠。但是在平板电脑模式下,您似乎不能同时 运行 超过 1 个应用程序。现在,当我打开我的应用程序时,之前位于顶部的应用程序会自行关闭,我只能在我的应用程序后面看到墙纸。我不能使用拆分视图模式,因为我的应用程序需要在物理上位于其他应用程序之上,我应该能够通过我的部分透明应用程序看到其他应用程序。

我已经检查过link: Start another application on top most in tablet mode 但这对我来说不是很有用,因为我需要我的应用程序正常启动,而不是通过另一个应用程序。

我个人已经看到至少一个第三方程序已经在桌面模式下执行此操作。请帮忙!

下面是我的 MainWindow.xaml 代码:

<Window x:Class="DictBook.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:DictBook"
    xmlns:controls="clr-namespace:DictBook.Controls"
    mc:Ignorable="d"
    Closing="Window_Closing"
    AllowsTransparency="True" WindowStyle="None"
    Title="MainWindow" Height="200" SizeToContent="WidthAndHeight">

<Window.Resources>
    <!--Some resources here-->
</Window.Resources>

<Window.Background>
    <SolidColorBrush Opacity="0.0" Color="Black"/>
</Window.Background>


<StackPanel>
    <!--Some controls here-->
</StackPanel>

下面是MainWindow.xaml.cs

public MainWindow()
    {
        Debug.WriteLine("MainWindow");

        Topmost = true;
        InitializeComponent();

        ShowInTaskbar = false;

        if (Properties.Settings.Default.Top > 0 && Properties.Settings.Default.Left > 0)
        {
            this.Top = Properties.Settings.Default.Top;
            this.Left = Properties.Settings.Default.Left;
        }

        PopulateMainWindow();
        Properties.Settings.Default.PropertyChanged += OnPropertyChanged;

    }

我建议你设置 Window.TopMost = true。

<Window x:Class="DictBook.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:DictBook"
xmlns:controls="clr-namespace:DictBook.Controls"
mc:Ignorable="d"
Closing="Window_Closing"
AllowsTransparency="True" WindowStyle="None"
Title="MainWindow" Height="200" SizeToContent="WidthAndHeight" Topmost="True">