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?
He did ask for a "truly modal" window. I don't think the article you link fits that request.
Randolpho
2009-07-17 20:05:52
It does reference the window.ShowDialog() solution if the main thrust of the article isn't enough.
John Fisher
2009-07-17 20:18:29
+1
A:
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.
Randolpho
2009-07-17 20:02:40
+1 for realizing a modal dialog isn't just a borderless popup which is what the web world commonly refers to nowadays.
Justin Niessner
2009-07-17 20:07:44
+3
A:
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".)
Noldorin
2009-07-17 20:11:38
Would this have a different effect than setting the Window's Owner property itself? Window.Owner takes another Window rather than a handle.
YotaXP
2009-07-17 20:48:22
@YotaXP: Yes, it would, as it makes the current window an *actual Win32 owner* rather than just a WPF one. Read the end part of the blog post for more info.
Noldorin
2009-07-17 21:09:01
I should have mentioned that it's being opened from a WPF window. I made the mistake of assuming since ShowDialog did not appear in the intellisense, that it was unavailable. Strangely, I cannot get the parent window to minimize with the dialog on my secondary screen, but I'm chalking this up to DisplayFusion, which acts odd with WPF apps on my system.Thank you.
2009-07-17 22:22:52