I would like to use XamDialog in my project but it seems the dialog must be in the visualtree before you can call Show. My project uses MVVM and the logic that determines when to show the modal is in my vm. Is it possible to use XamDialog with mvvm
Thanks in advance
Will
There's a better way. I just blogged about how to show the XamDialogWindow in a ViewModel without it being part of the visual tree. Of course, as the post says, I would still use a Dialog Service to show the dialog as your VM should be ignorant to Views.
http://brianlagunas.com/2013/05/18/showing-the-xamdialogwindow-from-a-viewmodel-in-silverlight-and-wpf/
Hi Will,
The simplest way you can do this is have a delegate in your view model that is hooked up to a method in your view. This method will take in an argument of type object that will be your data context for the dialog window. In your view model, whenever you want to show the dialog you would just call the delegate.
This way maintains MVVM because your view model doesn't know anything about what the delegate actually does and the method in your view is just showing a XamDialogWindow which is just UI code anyway.
Let me know if you have any questions on this.
I'm looking into this for you and will get back to you tomorrow.