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

Integration with PropertyChanged.Fody #3

Closed
igitur opened this issue Dec 8, 2015 · 2 comments
Closed

Integration with PropertyChanged.Fody #3

igitur opened this issue Dec 8, 2015 · 2 comments

Comments

@igitur
Copy link

igitur commented Dec 8, 2015

I have an MVVMLight application and I use PropertyChanged.Fody. I'm trying to use this library to display dialogs, but after closing the modal dialog, I get an error: DialogResult can be set only after Window is created and shown as dialog.

You can reproduce the problem by checking out your mvvm-light branch, and by running
Install-Package PropertyChanged.Fody -ProjectName DemoApplication to add Fody to DemoApplication.

Clicking any of the 2 buttons on the Modal dialog tab, entering some text and clicking OK results in the error.

@FantasticFiasco
Copy link
Owner

I've verified that I can reproduce the issue and will start working on it.

Thank you for reporting the issue.

@FantasticFiasco
Copy link
Owner

I've created a new release, v1.1.4. It has been uploaded to nuget.org and you should be able to use it in your application.

What I've done is to be defensive in MVVM Dialogs, making sure that the dialog result isn't set if it already has been set to the specific value.

But, and there is a but here, I think you might encounter other problems in your application if you incorrectly use MVVM Light in combination with PropertyChanged.Fody. The problem was that a property changed notification was sent twice for the property DialogResult. One was sent by MVVM Light by the usage of the Set method, the other was weaved in by Fody since PropertyChanged.Fody doesn't support the Set method.

This link is stating the supported frameworks, and sure MVVM Light is one of them. But it is stated that the only methods supported are:

  • For GalaSoft.MvvmLight.ObservableObject the method RaisePropertyChanged is supported
  • For GalaSoft.MvvmLight.ViewModelBase the method RaisePropertyChanged is supported

The Set method is not supported and is the reason as to why the property changed event is sent twice. I've verified this by investigating the IL code with ILSpy.

You need to question yourself if you need PropertyChanged.Fody at all. If you inherit the MVVM Light view models, why would you need to weave in property changed notifications?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants