Brian
Brian

Reputation:

Truly modal window possible?

Or would I have to do something like create a windows form and host the xaml inside it? Trying to get as consistent a look and feel as I can. If I can only do the latter, how do I achieve that?

Upvotes: 1

Views: 2929

Answers (2)

Noldorin
Noldorin

Reputation: 147240

This should be what you want:

var window = new MyWindow();
var helper = new WindowInteropHelper(window);
helper.Owner = this.Handle;
window.ShowDialog();

This is the key to ensuring correct behaviour upon minimise/restore. See this blog post for more information about the method.

(If this isn't quite what you need, perhaps you could define "truly modal".)

Upvotes: 4

Randolpho
Randolpho

Reputation: 56381

You can create custom dialog boxes, and they're modal. You can host a WPF Window within it and define buttons as modal closing buttons. That seems to be the best way to do a modal window, IMO.

Upvotes: 1

Related Questions