mvvm-dialogs icon indicating copy to clipboard operation
mvvm-dialogs copied to clipboard

ICloseable to close View from ViewModel

Open mysteryx93 opened this issue 2 years ago • 3 comments

While working on the Avalonia demos, I added a neat new feature to allow closing the View from the ViewModel

Sample ViewModel usage

All the user needs is to implement ICloseable from the ViewModel.

In DialogService, when showing the window, it hooks into the event to close the view

var dialog = CreateDialog(dialogType, ownerViewModel, viewModel);
if (viewModel is ICloseable c)
{
    c.RequestClose += (_, _) => dialog.Close();
}
dialog.Show();

Until the new version is ready, this could come in handy in the current library.

mysteryx93 avatar Dec 12 '21 04:12 mysteryx93

By the same token; can also add IActivable interface with event RequestActivate.

mysteryx93 avatar Dec 12 '21 07:12 mysteryx93

Thanks @mysteryx93!

I'm mentally building a roadmap for getting all functionality from #177 into this repo. Let's revisit this issue when we've gotten further down the road with #177.

FantasticFiasco avatar Jan 04 '22 13:01 FantasticFiasco

It's already implemented in my code branch. I just thought it could be added to the old code branch as well, which could be kept for compatibility reasons.

mysteryx93 avatar Jan 05 '22 04:01 mysteryx93

This repository has transitioned into a state where it's actively maintained but not actively developed. The README has been updated to reflect this. Thanks for the proposal but unfortunately this won't be implemented.

FantasticFiasco avatar Sep 18 '22 04:09 FantasticFiasco