Announcing the MVVM Foundation library

Today I published a new CodePlex project, called MVVM Foundation.  It is a  library of my favorite classes to use in MVVM applications.  Right now, it only contains classes suited for WPF applications, but eventually I will get around to adding in a Silverlight version, too.  If you would like to check it out, here’s the link:

12 Responses to Announcing the MVVM Foundation library

  1. Johan O says:

    This is really great Josh! I am actually using many of these classes already (the Mediator v2 and the RelayCommand) and they are truly great for building MVVM applications.

    If u haven’t started using MVVM together with the Mediator (Messenger) you are going to love it once you start using it. A very nice way of decoupling your view models I must say! And your code will also become very clean and easy to read and maintain.

    It wouldn’t surprise me if this “MVVM Foundation” would be a future “standard” project that many will use as a base for their MVVM applications. Atleast I hope so!

    Now all I am missing from you Josh is a good reference or sample project using these classes! It would be nice if the MVVM projects out therewhere a bit more “standardized”.

    Keep up the good work and thanks!

  2. Rudi Grobler says:

    Hi Josh,

    Excellent collection of classes… one quick note… I understand why you use the IWeakEventListner on the PropertyObserver but this limit the possibility of using this in Silverlight? Any sugestions on how to get this to work in SL? The messenger and VM base works perfectly in SL… Only the PropertyObserver?

  3. Rudi Grobler says:

    The SL toolkit has a WeakEventListener implementation…

  4. […] Announcing the MVVM Foundation library (Josh Smith) […]

  5. Hi Josh,

    An approach I have been taking is to use generics on my base ViewModel so that I can specify my model type:

    public abstract class ViewModelBase : INotifyPropertyChanged

    This allows me to strongly type my INotifyPropertyChanged implementation. Using your class as an example, I could rewrite RaisePropertyChanged to use the following signature:

    protected void RaisePropertyChanged(Expression<Func> x)

    Now, in my view models, my code looks like this:

    RaisePropertyChanged(x => x.LastName)

    No need to do all string validation you are doing. If your are interested, shoot me an email and I’ll send you the example I put together using MvvmFoundation.

  6. Great, none of that came through….site has anti-generic filters on:)

  7. Josh Smith says:

    @Johan – The Mediator class, called Messenger now, had a few bugs which I’ve fixed in MVVM Foundation. Also, I removed the ability to decorate callback methods with a special attribute. I felt that over-complicated things, and wasn’t really ‘core’ functionality. Also, a demo app that uses all of these classes is something I have thought about. If I find the time and motivation, I might create one. 🙂

    @Rudi – Please let me know if the SL Toolkit’s WeakEventListener support works out for you.

    @J.P. – I decided against using lambda expressions to specify property names to my ViewModelBase’s RaisePropertyChanged method, even though I use it in PropertyObserver’s Register method. The reason being, properties change a lot, and having to go through the Expressions API to get a property name every time a property changes seems like a potential performance problem. Granted, I haven’t empirically tested the performance characteristics of both approaches, so if you have facts that prove my suspicions to be unfounded, I’m all ears. Thanks!

  8. Saxon Chan says:

    I would like to know are they any plan for MVVM foundation emerge with PRISM2 ?

  9. Josh Smith says:

    Saxon, I have no idea.

  10. Nick M says:

    Thank you so much! I was so tired of copying the files into custom libraries. Now I have a one stop place to go to get updates!

  11. […] Recently, my good friend Josh Smith announced that he was putting together a set of MVVM foundation classes. In typical Josh fashion, these classes are hyper useful and hyper clever, and represent some of […]

  12. Johan O says:

    I just wanted add another comment about this great project.

    I am currently working on a number of applications that uses the MVVM pattern. The MVVM Foundation addresses many of the problems that you run into when the application grows.

    One concern that it does not help us with however is dialog boxes.

    What we have done is that we have created a special usercontrol that can spawn dialog boxes with the help of databinding. This works great but requires more work than simply calling a dlg.ShowDialog() and reading the results.

    Now I’ve read that many of the WPF disciples recommend using a “dialog box” service instead.

    So now Josh I wonder if you have been thinking of adding such a service to the MVVM foundation, to lay the last piece of the puzzle so to say.

    Maybe a service that can open a dialog box to which you pass a ViewModel into it’s constructor and this is shown inside the dialog box. Or something along that path?

%d bloggers like this: