rakete
rakete

Reputation: 3051

WPF window in front of another WPF window

I have a WPF-window, in this you can click a button to see a new window. Now I want to disable, that you can click the main-window. It should be like a MessageBox.

Upvotes: 1

Views: 657

Answers (4)

Restuta
Restuta

Reputation: 5903

Try this:

 dialogYouNeedToShow.Owner = App.Current.MainWindow;
 dialogYouNeedToShow.ShowDialog();

ShowDialog will always show your dialog as a modal one, so you won't have access to background form.

Upvotes: 2

ZombieSheep
ZombieSheep

Reputation: 29963

Do you mean

MessageBox.Show() 

or

myWindowName.ShowDialog() 

?

Upvotes: 0

Mark Carpenter
Mark Carpenter

Reputation: 17775

You're looking for Window.ShowDialog()

Upvotes: 2

Brian R. Bondy
Brian R. Bondy

Reputation: 347466

You want to use dialog.ShowDialog().

Modeless dialogs (via dialog.Show) are ones that you can interact with the background window. Modal dialogs (via dialog.ShowDialog() are ones that don't allow you to interact with the parent window.

Upvotes: 3

Related Questions