Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have non-modal dialog close when owner closes? #107

Closed
metal450 opened this issue Jun 5, 2020 · 7 comments
Closed

Have non-modal dialog close when owner closes? #107

metal450 opened this issue Jun 5, 2020 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@metal450
Copy link

metal450 commented Jun 5, 2020

I'm using this to show a non-modal dialog, i.e.

App.DialogSvc.Show<Something>(this, somethingVm);

The application is a tabbed document editor, where the non-modal dialog shown above is a pop-up with some tools that apply to the current document. The owner is the VM representing the document. The issue: when the current document tab (of the owner VM) is closed, the non-modal dialog remains open. Under old WinForms, when I'd open a non-modal window & pass the current window as its owner, closing the current window would implicitly close the child. It's fairly obvious why this doesn't happen with MVVM, but I'm at a loss as to how a similar behavior could be achieved with MVVM.

Basically, I'm trying to figure out a way - either manually or automatically - to have the non-modal dialog close when the view of the VM from which it was opened closes.

@metal450 metal450 added the bug Something isn't working label Jun 5, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Jun 5, 2020

Hi there and welcome to this repository!

A maintainer will be with you shortly, but first and foremost I would like to thank you for taking the time to report this issue. Quality is of the highest priority for us, and we would never release anything with known defects. We aim to do our best but unfortunately you are here because you encountered something we didn't expect. Lets see if we can figure out what went wrong and provide a remedy for it.

@FantasticFiasco
Copy link
Owner

Hi!

I'll see if we can't get a sample showing this scenario. But since it's a National day here in Sweden, it will probably be a few days until I have a working sample.

@metal450
Copy link
Author

metal450 commented Jun 6, 2020

No prob - thanks for the quick reply!

@FantasticFiasco
Copy link
Owner

I've created a very small sample here. Closing a non-modal dialog using MVVM is not something that is supported by this library, but it can be achieved by attached properties you write on your own, as demonstrated in the sample.

Would you consider this to be a sufficient solution for your problem?

@metal450
Copy link
Author

metal450 commented Jun 7, 2020

Perfect solution! Thank you again!

@metal450 metal450 closed this as completed Jun 7, 2020
FantasticFiasco added a commit that referenced this issue Jun 7, 2020
Support for closing a non-modal dialog using `IDialogService.Close`.

Closes #107
@FantasticFiasco
Copy link
Owner

I wasn't happy with the proposed solution. The fact that you had to implement your own helper class for closing the non-modal dialog just bugged me.

I've now released a new version of this library (v7.1.0), a version where you can close your dialog. I've updated the sample linked above, please have a look at it and use the new version of MVVM Dialogs in your code.

I've also mentioned you in CHANGELOG.md since you are the reason this feature got implemented.

Anyway, best of luck on all your future endeavours, and don't hesitate to open a new issue if you find anything to your disliking.

@metal450
Copy link
Author

metal450 commented Jun 7, 2020

Very cool, thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants