A while ago I began to write a blog tutorial about how to create a modular WPF application using MVVM and MEF. I have decided to present it as a screencast instead, so here is the first part. It uses WPF, but a lot of the techniques I show apply equally well to Silverlight.

My approach is not to start off using MVVM and MEF (or any of the more fully featured WPF frameworks), but to introduce these libraries and design patterns at the point at which they make sense. Hopefully this will make it clearer why we might actually want to use them in the first place.

In this first video I create a very simple application with a menu allowing you to switch between two modules, and show how MEF enables us to work around violations of the “Open Closed Principle”.

I’ve got at least one more episode planned which hopefully will appear shortly and introduce MVVM to make our application more easily testable. If there is demand, I may also post my notes and upload my mercurial repository to bitbucket.

Another reason for presenting this as a screencast is that I am planning to create some NAudio screencasts in the future, and so I need to get some practice in. This one is a little raw as I didn’t do a practice beforehand, but I have tried to keep things flowing along at a reasonable pace. I also know the sound quality isn’t brilliant. Let me know if you think the resolution is acceptable.

Want to learn about how to create modern looking WPF applications with MahApps.Metro? Be sure to check out my Pluralsight course Creating Modern WPF Applications with MahApps.Metro.
Vote on HN


Comment by Pierre Mengal

Please keep doing those great screencasts! Don't forget to turn off the cell phone next time ;)

Comment by Mark H

Yeah, sorry about that ;) Hopefully will find some time to get part 2 done soon. I've already written the code; just need to record the screencast.

Comment by Scott

thanks for the screencast, it was very easy to follow and understand! can't wait for the next installment when you split it up to follow the mvvm pattern. it would be nice to see this example with modules in separate assemblies.

Comment by Mark H

hi Scott, modules in separate assemblies is one of the things on my list to cover (possibly in part 4?). Also, part 2 is out now.

Comment by Scott

hi mark,

i just found part 2, very good again !

looking forward to more in this series.

thanks, scott

Comment by Jerry Davis

Mark, I don't know how long I've been searching for a simple, straightforward demo which covers view changing and navigation in WPF/MVVM. This series fills a *HUGE* void between the trivial single-view apps and the esoteric discussions of 3rd party frameworks. As for a request, I would love to see the demo application cover some more Line-of-Business topics, like messaging and passing data around. Well done, and I look forward to coming back for more!

Comment by Mark H

thanks Jerry, I've been on various holidays this summer, but I'll bear your suggestions in mind when I get back to continuining with this series

Comment by James Smith

where is part 3. and where is the source code.

James Smith
Comment by Mark H

@sorry James, still haven't made part 3, been doing other stuff. Maybe later this year

Comment by James Smith

dont know when you will upload the third part of video. can you upload the code. i need that. that will be very helpful for me.

James Smith
Comment by Anonymous

Thank you very much for the good tutorial.

Comment by John Peters

Very nice intro to MEF. I like your technique of starting from what-is and moving to what-should-be.

This very clearly shows how one's mindset needs to change with respect to thinking in terms of the future.

comments powered by Disqus