简体   繁体   English

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

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

I am currently working on a personal win10 wpf project, a simple tool that can help me use other programs on my win10 tablet. 我目前正在从事个人win10 wpf项目,这是一个简单的工具,可以帮助我在win10平板电脑上使用其他程序。

So one of the requirement is that this program should run in the unmaximized mode, with other applications physically underneath it. 因此,要求之一就是该程序应在非最大化模式下运行,而其他应用程序则应位于其下。 You can find few examples of this kind of behavior in virtual keyboard programs, eye-droppers, screenshot taking programs. 在虚拟键盘程序,滴管,屏幕截图程序中,您几乎找不到这种行为的示例。 They run on top of other applications, and you can still see the other application behind still running. 它们在其他应用程序之上运行,您仍然可以看到后面的其他应用程序仍在运行。

My application runs fine on the Desktop mode, because you can run multiple windows at the same time all overlapping each other. 我的应用程序在桌面模式下可以正常运行,因为您可以同时运行多个相互重叠的窗口。 But in the tablet mode, it seems you cannot run more than 1 application at a time. 但是在平板电脑模式下,似乎您一次不能运行多个应用程序。 Right now when I open my application, the application that was previously on the top closes itself and all I can see behind my application is the wallpaper. 现在,当我打开我的应用程序时,先前位于顶部的应用程序会自行关闭,而我看到的所有内容就是墙纸。 I cannot use the split view mode, because my application needs to be physically on top of other applications and I should be able to see the other applications through my partially transparent application. 我不能使用拆分视图模式,因为我的应用程序需要在物理上位于其他应用程序的顶部,并且我应该能够通过部分透明的应用程序看到其他应用程序。

I have already checked this link: Start another application on top most in tablet mode But this was not very useful in my case because I need my application start normally, not through another application. 我已经检查了此链接: 以平板电脑模式在最上面启动另一个应用程序,但是这对我来说不是很有用,因为我需要正常启动应用程序,而不是通过另一个应用程序启动。

I have already personally seen at least one third-party program that already does this in the desktop mode. 我已经亲眼目睹了至少一个第三方程序已经在桌面模式下执行此操作。 Please help! 请帮忙!

Below is my MainWindow.xaml code: 下面是我的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>

Below is the MainWindow.xaml.cs 以下是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;

    }

I suggest you to set the Window.TopMost = true. 我建议您设置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">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM