I am trying to use the Mahapps dialog boxes in my project but have been unable to get them to work when trigger from a ReactivUI command in my ViewModel.In the view's XAML, I have registered the dialog.
xmlns:dialogs="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
dialogs:DialogParticipation.Register="{Binding}"
I also have a button which is bound to the ShowDialog command.
this.BindCommand(viewModel, vm => vm.ShowDialog, x => x.button);
Finally, in my ViewModel, I have the RxUI command and the dialogcoordinator instance set.
public MainWindowViewModel(IDialogCoordinator dialogCoordinator)
{
_dialogCoordinator = dialogCoordinator;
ShowDialog = ReactiveCommand.CreateFromTask(async () =>
{
await _dialogCoordinator.ShowMessageAsync(this, "Message from VM", "MVVM based dialogs!");
});
ShowDialog.ThrownExceptions.Subscribe(ex => Console.WriteLine(ex.ToString()));
}
No matter what I have tried it always throw the same error which is
System.InvalidOperationException: Context is not registered. Consider using DialogParticipation.Register in XAML to bind in the DataContext.
I am not sure if there is anything else needed to get the dialog to work or if I am just using the commands in RxUI incorrectly