繁体   English   中英

在平板电脑模式下最顶层启动另一个应用程序

[英]Start another application on top most in tablet mode

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

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

用于启动exe文件的代码

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

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

它仅在平板电脑模式下无法正常运行(并且我的应用程序仅针对平板电脑)。

任何帮助表示赞赏..!

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

看我的代码。 希望它能为您提供帮助。

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()
没有设置OwnerFilterWindow具有可笑的行为。

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

Moerfi使用Owner = GetParentWindow()的解决方案非常成功,非常感谢该解决方案。 它还解决了我遇到的另一个问题。

我正在编写适用于Surface 3的应用程序,该应用程序可在平板电脑模式下的Windows 10 Pro上运行,每当关闭MessageBox或自定义对话框控件而不是返回父窗口时,Win 10就会进入开始菜单。

仿佛一旦打开对话框控件,父窗口便被置于背景中,所以当关闭对话框控件时,没有活动窗口可供Win 10切换回。

在子对话框控件上设置所有者可以解决该问题。 非常感谢你。

暂无
暂无

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

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