在平板电脑模式下启动另一个应用程序 [英] Start another application on top most in tablet mode

查看:230
本文介绍了在平板电脑模式下启动另一个应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从我的应用程序运行另一个.exe时,它在后台启动,而不在屏幕顶部显示该应用程序,而是在平板电脑模式的主屏幕上显示,它在正常的桌面模式下运行正常,但是当我在Windows 10中运行它时

When I run another .exe from my application it starts in the background and does not show the application on top of the screen instead shows tablet mode home screen , it's working fine in normal desktop mode but when I run it in Windows 10 Tablet mode then it does not show on top it starts in the background.

我使用了 myWindow.TopMost = true; ,但在Windows 10平板电脑模式下无法正常工作。

I've used myWindow.TopMost = true; , but it does not work as intended in Windows 10 Tablet Mode.

用于启动exe文件的代码

Code used to start exe file

Process p = new Process();
p.StartInfo.RedirectStandardOutput= true;
p.RedirectStandardInput = true;
p = Process.Start("myApp.exe");
p.WaitForExit();

我正在调用(开始)的exe是我自己的exe应用程序(不是系统应用程序),我正在Windows 10上运行应用程序。

the exe I'm invoking(starting) is my own exe application(it's not system app), I'm running app on windows 10.

在平板电脑模式下它仅不能在顶部运行(并且我的应用程序仅针对平板电脑)。

It's only not working on top in Tablet mode( and I'm targeting my application only for Tablets).

感谢您的帮助。.

推荐答案

当我遇到类似情况时, (它与平板电脑无关,也不与Windows 10相关。只有 WPF TopMost 标签具有相似性),我将向您展示如何解决它:
希望FilterWindow始终为TopMost(但仅限于我的应用程序,而不是操作系统中的整个应用程序)

As I faced a similar situation, (it is not tablet, or windows-10 related. Has similarities only by WPF and TopMost tags) I'll show you how I resolve it: I would like to have the FilterWindow always TopMost (but only over my application, not over entire set of apps in my Operating System)

请参阅我的代码。

private void OnFilter() {   
    var filterViewModel = ViewModelLocator.FilterViewModel;

    /* ... */

    var filterWindow = new FilterWindow {
        DataContext = filterViewModel,
        Owner = GetParentWindow()
    };
    filterWindow.ShowDialog();
    SelectedIndex = 0;
}

private static Window GetParentWindow() {
    Window parent = null;

    var activeWindows = Application.Current.Windows.Cast<Window>().Where(item => (item).IsActive).ToList();
    if (activeWindows.Any()) {
    parent = activeWindows[activeWindows.Count - 1];
    }
    else {
        foreach (var item in 
            Application.Current.Windows.Cast<object>().Where(item => item.GetType().Name == typeof(RibbonWindow).Name)) {
            parent = item as Window;
        }
    }
    return parent;
}

魔术就是 Owner = GetParentWindow()

如果未设置 Owner ,则 FilterWindow 的行为很可笑。

The magic is Owner = GetParentWindow().
Without setting the Owner the FilterWindow had a ridiculous behavior.

希望它对您有所帮助。如果否,我将删除回复。 (不适用于评论)

Hope it helps you. If no, I will remove the response. (it does not fit in a comment)

这篇关于在平板电脑模式下启动另一个应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆