Updates made to MVVM Foundation

I set aside some time today to add some goodness, and remove some badness, from my MVVM Foundation library on CodePlex.  Special thanks go to Matt Heffron for his great work on making the Messenger class much safer and user-friendly.  Here is a listing of the changes:

  • Added safety checks and helpful error messages in Messenger for callback registration and message broadcasting. Unit tests were added to verify this behavior.
  • Ensured that Messenger notifies colleagues of a message in the order they registered for that message. Unit tests were added to verify this behavior.
  • Fixed an issue in an ObservableObject unit test where it failed in a Release build.

It’s exciting for me to see the improvements and ideas suggested by people using MVVM Foundation!  I appreciate the time people have contributed toward making the library better.  I hope there are no hard feelings when I reject a proposed feature.  :)

You can get the latest source code here: http://mvvmfoundation.codeplex.com/SourceControl/ListDownloadableCommits.aspx

21 Responses to Updates made to MVVM Foundation

  1. Yazid says:

    Josh,

    I have just downloaded the code from code project nd thea lots of files missing, for exmaple Messenger.cs, observableObject and relayCommand.

    TIA
    Yaz

  2. […] Updates made to MVVM Foundation (Josh Smith) […]

  3. Josh Smith says:

    Yazid,

    I just downloaded the latest source code from CodePlex and got all of the files. I’m not sure why you didn’t get them all. Try downloading it again, perhaps?

    Thanks,
    Josh

  4. Yazid says:

    Hi Josh,

    Downloaded it again and I cannot see the files, in addition in the folder WpfDemoApp and the ViewModels and Models folders there is no code at all.

    I have question about the previous code, in the delegatecommand you have unit tests, but you do not have one showing how to test the CanExecuteChanged event.

    TIA
    Yaz

  5. Josh Smith says:

    Yazid,

    I am baffled as to why you keep receiving an incomplete source code package. No one else has reported this problem, and I can’t reproduce it. Very strange…

    I’m not sure what your question is. Are you asking why I am not testing the event, or how to test the event? If the former, because RelayCommands hook into WPF’s command manager to be queried for their can-execute status. This happens whenever the built-in commands are queried. There’s no need to test that. If you’re asking how to test the event, then you could hook the event, call CommandManager’s InvalidateRequerySuggested method, and your event handling method should (will) be called.

  6. Yazid says:

    Hi Josh,

    Do you have an example or a link showing InvalidateRequerySuggested in a NUNIT.

    Cheers
    Yaz

  7. Josh Smith says:

    No, I don’t. Now that you ask, I have never tried that scenario out. I’m not sure if CommandManager will work properly when running in a unit test. So, to answer your question: I’m not sure.😀

  8. Yazid says:

    Hello Again,

    I have tried InvalidateRequerySuggested and I never been able to get it to work. If I do I will let you know.

    Very cool library.

    Thx
    Yaz

  9. 9eFish says:

    Updates made to MVVM Foundation « Josh Smith on WPF…

    9efish.感谢你的文章 – Trackback from 9eFish…

  10. […] Updates made to MVVM Foundation (Josh Smith) […]

  11. Stephan Puchegger says:

    Dear Josh!

    One humble question: Would you be willing to dual-license this really great library? Perhaps MS-PL and LGPL?
    The reason I am asking this is because I am currently developing a data evaluation tool here at the University of Vienna and I would love to license it under the GPL. Why the GPL? I want everybody (well, a few people) to be able to use it, see how the results are produced and would like to keep it that way if anyone modifies or extends the program. The wheel is invented far too often over and over again in the scientific community.

    Thanks!

    Stephan

  12. Josh Smith says:

    Stephan,

    Sorry, I don’t know what an LGPL license means. How are the LGPL rules different from the MS-PL?

  13. Stephan Puchegger says:

    Dear Josh!

    First: I am sorry to bother you with this licensing crap.

    I am not a lawyer. The general opinion seems to be that the MS-PL is not compatible with the GPL or most other open source licenses. I asked, because I do not want to violate your license terms.

    As far as I have read the problem seems to be the first sentence in section 3(D) of the MS-PL:

    “(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. …..”

    This means that I cannot distribute my part of the sourcecode under the GPL (or most other open source licenses like BSD or MIT) if I include your library in the distributed VS solution, because that would make the VS solution a derivative work of your library, that would need to be distributed under the MS-PL.

    The LGPL istself states that you can copy the source code, modify it, and you can link the library to code with a different license. You need to publish any changes to the LGPLed sourcecode if you distribute the binary of a modified LGPL library or program. (http://en.wikipedia.org/wiki/LGPL) The LGPL does not, as far as I know, have any restriction like section 3(D) in the MS-PL.

    I do not want to advoke the LGPL (or GPL) here. If you find any other license that you like better and that allows the distribution with software with a different license, please use that license. Perhaps the MIT-X11 license (http://www.opensource.org/licenses/mit-license.html) is more to your liking, which is used by the MONO-Project for the class libraries (http://www.mono-project.com/Licensing)

    The general problem is, that this whole licensing business is a mess. There are lots of incompatible licenses out there and it is harder and harder to navigate this jungle if one is not a lawyer.😦

    Please do not feel forced to do anything about this if you are not comfortable with dual licensing your software. I just wanted to ask.

    Thanks a lot for listening!

    Stephan

  14. Frickel says:

    Do you plan to keep up with Cinch and integrate more helper classes?

  15. Josh Smith says:

    @Stephan – What a headache this licensing crap is. I hereby give you full permission to do whatever you want with MVVM Foundation.🙂

    @Frickel – Yes and yes.

  16. Stephan Puchegger says:

    Dear Josh!

    Thanks a lot!🙂

    Best regards & Best wishes!

    Stephan

  17. RyanM says:

    This example (and the accompanying MSDN article on MVVM) has finally clarified a lot of the cloudiness I’ve had trying to develop a “real” application using solid design patterns in WPF. Thanks so much for your continued knowledge sharing, Josh!

    One aspect that still confuses me is integration of the UI workflow with Blend. As an example, I can’t understand how to use Blend to do all the UI look-and-feel design (at least directly) on the demo project for two reasons.
    1) The UI is data driven and thus Blend won’t show things that only appear when the data bindings are bound to, well, data. This only happens at run time.
    2) The Visual Studio designer seems to be hopeless at displaying resources if they’re not directly in the file (data templates, styling, etc). Blend is occasionally better, but I’ve never figured out how to do anything but the most simplistic things found in beginning tutorials. Nothing that would actually let a designer use the tool to build a real application.

    The closest thing to a practical workflow I’ve found is creating a bunch of UI mockups with static data, doing the styling, then extracting and refactoring the resulting xaml into my real application. Good for a one-shot effort, but that’s about it.

    Anyone able to shed some light on this? I’m willing to read articles/books/etc. just very lost where to look.

    Thanks in advance,
    Ryan

  18. Hi Ryan,

    I am preparing a rather long series of articles about MVVM and the way I use it to facilitate the designer-developer workflow. It includes the creation of design time data.

    I recently published a MVVM “light” toolkit that contains helper components to make creating MVVM applications easier, and especially adding design time data. The toolkit is available for download at http://www.galasoft.ch/mvvm/getstarted

    For the moment there is not too much documentation, but stay posted. When you create a new MVVMLight project, you will see that it creates a functional application, including design time data. You can then open the project into Blend and see the design time data, and be able to design it. This is the approach we try to use on the projects we work on.

    Note however that this does not always work. An alternative is to use the built in functionality in Blend to create design time data. You will find more info about this on Christian Schormann’s blog http://electricbeach.org/

    Also, sometimes I need to resort to the techniques you describe: Isolate the component to be designed, create templates in a separate project, and then integrate back in the real application. As usually, it depends what situation you’re in🙂

    HTH,
    Laurent

  19. RyanM says:

    Josh, thanks for the quick reply! These look good. Hopefully they’ll be useful to others on the same quest.

  20. RyanM says:

    Thank you Laurent also. Looks like we posted at the same time.

%d bloggers like this: