WPF:在Win10 Tablet模式下在另一个应用程序上打开应用程序

时间:2018-10-29 04:01:40

标签: wpf windows windows-10 tablet-pc

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

因此,要求之一是该程序应该以非最大化模式运行,而其他应用程序则位于其下。 在虚拟键盘程序,滴管,屏幕截图程序中,您几乎找不到这种行为的示例。它们在其他应用程序之上运行,您仍然可以看到仍在运行的其他应用程序。

我的应用程序在桌面模式下可以正常运行,因为您可以同时运行多个相互重叠的窗口。但是在平板电脑模式下,似乎您一次不能运行多个应用程序。现在,当我打开我的应用程序时,先前位于顶部的应用程序会自行关闭,而我看到的所有内容就是墙纸。我不能使用拆分视图模式,因为我的应用程序需要在物理上位于其他应用程序的顶部,并且我应该能够通过部分透明的应用程序看到其他应用程序。

我已经检查了此链接: 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;

    }

1 个答案:

答案 0 :(得分:0)

我建议您设置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">