gpt4 book ai didi

c# - 在平板电脑模式下在最上面启动另一个应用程序

转载 作者:太空狗 更新时间:2023-10-30 01:31:59 24 4
gpt4 key购买 nike

当我从我的应用程序运行另一个 .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 会出现荒谬的行为。

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

关于c# - 在平板电脑模式下在最上面启动另一个应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38742821/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com