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.
I've used myWindow.TopMost = true;
, but it does not work as intended in Windows 10 Tablet Mode.
Code used to start exe file
Process p = new Process();
p.StartInfo.RedirectStandardOutput= true;
p.RedirectStandardInput = true;
p = Process.Start("myApp.exe");
p.WaitForExit();
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).
Any help is appreciated..!
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)
See my code. May it'll helps you.
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;
}
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)
Moerfi's solution of using Owner = GetParentWindow()
worked surperb, much thanks for this solution. It also solved another problem I had.
I am writing an application for Surface 3 that runs on Windows 10 Pro on tablet mode, whenever a MessageBox
or custom dialog control box is closed, as opposed to going back to parent window, Win 10 goes to start menu.
As if once the dialog control is opened the parent window is being placed into background, so when dialog control is closed there is no active window for Win 10 to switch back.
Setting owner on child dialog control solved that problem. Thank you very much.