开发者

WPF window in front of another WPF window

开发者 https://www.devze.com 2022-12-17 00:55 出处:网络
I have a WPF-window, in this you can click a button to see a new window. Now I want to disable, that y开发者_开发知识库ou can click the main-window. It should be like a MessageBox.You want to use dial

I have a WPF-window, in this you can click a button to see a new window. Now I want to disable, that y开发者_开发知识库ou can click the main-window. It should be like a MessageBox.


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.


You're looking for Window.ShowDialog()


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.


Do you mean

MessageBox.Show() 

or

myWindowName.ShowDialog() 

?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号