Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

ShowDialog() displays no data but Show() does

Maybe this can’t be answered without context but when I use Show():

TestView test = new TestView()
            {

                Owner = Application.Current.MainWindow
            };
            test.Show();

Everything works fine, the events are fired and my textbox/comboboxes are populated with data on the test view. But when I use ShowDialog() nothing is populated. Anyone know a reason why? I want a modal window.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

This is by design.

As by documentation:

When a Window class is instantiated, it is not visible by default. ShowDialog shows the window, disables all other windows in the application, and returns only when the window is closed. This type of window is known as a modal window.

Modal windows are primarily used as dialog boxes. A dialog box is a special type of window that applications use to interact with users to complete tasks, such as opening files or printing documents. Dialog boxes commonly allow users to accept or cancel the task for which they were shown before the dialog box is closed.

Thus, the ShowDialog is blocking until the window is closed.

This means that dealing with events and similar, specifically from the Owner window will not work.

If you have additional questions, please show the relevant code with the events and how you populate them.

If for some reason you need a full blocking window – it is possible; but we will need more details.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading