开发者

WPF equivalent of Form.ShowDialog(IWin32Window)

In WPF we have Window.ShowDialog() which allows showing a modal dialog box.

In WinForms there is similar functionality but it also has an overload Form.ShowDialog(IWin32Window) which allows an IWin32Window owner to be passed in. That way the new dialog is not modal, and always maintains a z-order directly above its owner.

How would I get this same functionality using WP开发者_StackOverflow社区F?


Use the Owner property on a Window.


To expand on @Jonathan.Peppers's answer:

Say you had a Window you named FooWindow, and in BarWindow.cs you wanted to create and execute an instance. You can create a modal version of FooWindow as simple as this:

new FooWindow(){ Owner = this }.ShowDialog();

That would assume you didn't need a reference to you instance, obviously, but you get the idea?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜