As you see, I'm trying a new way to show custom dialog with MahApp.Metro in MVVM.
I can't reference MahApps.Metro.Controls.Dialogs
in VM directly for using
dialogCoordinator.ShowMetroDialogAsync(..., BaseMetroDialog dialog, ...)
,
because BaseMetroDialog
is an UI element(breaking MVVM).
So I'm trying define my custom dialog in xaml, then calling ShowMetroDialogAsync
via ObjectDataProvider
. But I don't know how to get reference of DataContext(the VM)
for passing to ObjectDataProvider.MethodParameters
as the first param.
button for trigger ObjectDataProvider
:
There's nothing wrong with a a service that shows the dialog. This way, the view model does not know of the view and you do not need over-complicated xaml constructs.
Or you go for prism's built-in popup system with interaction requests.