Hosting UserControl on ModernDialog

Mar 1, 2013 at 3:44 AM
Hi,

In the given example, you are launching ModernDialog by setting Content to LoremIpsum usercontrol. Here usercontrol displays static text.

new ModernDialog {
            Title = "Common dialog",
            Content = new LoremIpsum()
        }.ShowDialog();
I wanted to do data operations and have OK and Cancel button. In this case, how LoremIpsum usercontrol which button is clicked? OK or Cancel?

Please provide some example on this front.

Thanks & Regards,
Charkravarti.B.
Coordinator
Mar 4, 2013 at 8:08 PM
You can access the hosting dialog by executing the following code in the usercontrol code:
var dlg = Window.GetWindow(this) as ModernDialog;
if (dlg != null) {
  ..
}
Mar 6, 2013 at 10:35 AM
Thank you.

But here my problem is that I am using MVVM pattern. So I need to close ModernDialog from ViewModel. Do you have any suggestions for this?

Regards,
Chakravarti.B.
Coordinator
Mar 6, 2013 at 3:24 PM
Closing a ModernDialog instance is not different from closing any WPF dialog in MVVM. Setting the DialogResult from a view model is challenging, since DialogResult is not a dependency property. Suggestions to solve this can be found at this stackoverflow question.

Also, you can create a custom dialog by deriving from ModernDialog (exactly the same as how you derive from ModernWindow).
Mar 7, 2013 at 2:35 AM
Thank you.

But here my problem is that I am using MVVM pattern. So I need to close ModernDialog from ViewModel. Do you have any suggestions for this?

Regards,
Chakravarti.B.
Mar 7, 2013 at 2:36 AM
Thank you.

But here my problem is that I am using MVVM pattern. So I need to close ModernDialog from ViewModel. Do you have any suggestions for this?

Regards,
Chakravarti.B.
Mar 7, 2013 at 3:43 AM
Can you please tell me the reason behind exposing CloseTrueCommand, CloseFalseCommand as public get properties?
Mar 7, 2013 at 8:25 AM
Can you please tell me the reason behind exposing CloseTrueCommand, CloseFalseCommand as public get properties?