Prevent the user from using the mainwindow window while another window is open

0

I have an application in WPF following the MVVM standard and in a certain part of the application I show a ProgressBar that I implemented in a separate view for the user and, while this progressBar is running, I would need the user to be unable to touch any other window, as well as the method "ShowDialog ()" does however, if I display the progressBar using ShowDialog () the main app stops the process because it is waiting for the result of my view ...

HereisthepartoftheCodethatIcallprogressBar

_progressBar=newPackProgressBar("Packing",BasicVariableCollection.Count - 1);
_progressBar.Show();

Where "PackProgressBar" is the name of my Progressbar View class, which is of the "Window" class

    
asked by anonymous 08.10.2018 / 18:33

2 answers

0

I was able to work out a solution to the problem by using the "IsEnabled" property of the mainwindow so, setting this property to "false" by calling progressbar and then to "true" in the RunWorkerCompleted of the asynchronous task

 _progressBar = new PackProgressBar("Packing", BasicVariableCollection.Count - 1);
 _progressBar.Show();
 System.Windows.Application.Current.MainWindow.IsEnabled = false;

and

System.Windows.Application.Current.MainWindow.IsEnabled = true;
_progressBar.Close();
    
08.10.2018 / 19:00
0

You should use Form.ShowDialog .

ShowDialog() method instead of Show() when you display the child form.

    
08.10.2018 / 18:40