当我从我的应用程序运行另一个.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上运行应用程序。
它只是在平板电脑模式下无法正常工作(我的目标只针对平板电脑)。
感谢任何帮助..!
答案 0 :(得分:3)
当我遇到类似的情况时,(它不是平板电脑,或者与Windows-10相关。只有 WPF 和 TopMost 标签有相似之处)我会告诉你我如何解决它: 我想让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()
如果不设置Owner
,则FilterWindow
会有一种荒谬的行为。
希望它对你有所帮助。如果不是,我将删除回复。 (它不适合评论)
答案 1 :(得分:0)
Moerfi使用Owner = GetParentWindow()
使用surperb的解决方案,非常感谢此解决方案。它还解决了我遇到的另一个问题。
我正在编写一个在平板电脑模式下在Windows 10 Pro上运行的Surface 3应用程序,只要关闭MessageBox
或自定义对话框控件框,而不是返回到父窗口,Win 10就会启动菜单。
好像打开对话框控件后,父窗口将被置于后台,因此当关闭对话框控件时,Win 10没有活动窗口可以切换回来。
设置子对话框控件的所有者解决了这个问题。非常感谢你。