Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a small WPF application, say SubWPF , which initially displays a home window that allows the user to browse a file. I am launching this wpf application on the button click of another application say MainWPF. In short, when I click on "Launch Sub", SubWPF.exe is launched from MainWPF through Process class as given below.

Process p = new Process();
p.StartInfo.FileName = "SubWPF.exe";
       
p.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
p.StartInfo.UseShellExecute = false;
p.StartInfo.Verb = "runas";
p.Start();


The issue is in the background I have the MainWPF window. I need the subwpf to be always on top and prevent the user from clicking background buttons of mainwpf. To be precise, the behaviour of a showdialog() needs to be achieved.

What I have tried:

I have tried using  TopMost=true for subwpf home window, but it didn't achieve the functionality as in my subwpf once the user selects a file in the home window, this window is closed and another window showing the contents of file is displayed. Setting TopMost=true is not allowing me to close the file selection window.
Posted
Updated 7-May-21 1:26am
Comments
[no name] 5-May-21 14:06pm    
The way you've described it, there's no point to "Process". If MainWPF is "launching" SubWPF only to have it come up modal, Main might as well show a dialog. I think there's a problem with your concept of "click through".

1 solution

The only way I can think of to do what you want is to disable the entire main window.

When the sub-process is launched, set IsEnabled to false in the main window class.

BTW, this is a stupid design decision. Why not just open a form within the main app itself?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900