【问题标题】:WPF: Open application on top of another in Win10 Tablet modeWPF:在 Win10 平板电脑模式下在另一个之上打开应用程序
【发布时间】:2019-04-01 23:26:26
【问题描述】:

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

因此,其中一项要求是该程序应在未最大化模式下运行,而其他应用程序物理上位于其下。 您可以在虚拟键盘程序、滴管、截屏程序中找到一些此类行为的示例。它们运行在其他应用程序之上,您仍然可以看到后面的其他应用程序仍在运行。

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

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

    }

【问题讨论】:

    标签: wpf windows windows-10 tablet-pc


    【解决方案1】:

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

    【讨论】:

    • 感谢您的及时评论!我已经在使用 Topmost=true;在窗口的 .cs 文件中(编辑问题)。似乎 topmost=true 在桌面模式下工作正常,但在平板电脑模式下,无论我如何设置值,每次启动应用程序时,后面的应用程序都会关闭。
    猜你喜欢
    • 2023-03-09
    • 2014-09-18
    • 1970-01-01
    • 1970-01-01
    • 2017-04-12
    • 2014-12-03
    • 2023-04-05
    • 2023-03-03
    • 1970-01-01
    相关资源
    最近更新 更多