Taking a step back before I dive into the details and full-on coding fun, I wanted to once again respond to a comment on my last post to clear up some things in regards to how I'm setting up my project and some of the choices I've made.  Aka, thanks Ben. :)

Prism Project Setup

For starters, I'm not the ideal use case for a Prism application.  In most cases where you've got a one-man team, Prism can be overkill as it is more intended for large teams who are geographically dispersed or in applications that have a larger scale than my Recruiting application in which you'll greatly benefit from modularity, delayed loading of xaps, etc.  What Prism offers, though, is a manner for handling UI, commands, and events with the idea that, through a modular approach in which no parts really need to know about one another, I can update this application bit by bit as hiring needs change or requirements differ between offices without having to worry that changing something in the Jobs module will break something in, say, the Scheduling module. 

All that being said, here's a look at how our project breakdown for Recruit (MVVM/Prism implementation) looks:

Application Layout

This could be a little misleading though, as each of those modules is actually another project in the overall Recruit solution.  As far as what the projects actually are, that looks a bit like this:

  • Recruiting Solution
    • Recruit (Shell up there) - Main Silverlight Application
    • .Web - Default .Web application to host the Silverlight app
    • Infrastructure - Silverlight Class Library Project
    • Modules - Silverlight Class Library Projects

Infrastructure & Modules

The Infrastructure project is probably something you'll see to some degree in any composite application.  In this application, it is going to contain custom commands (you'll see the joy of these in a post or two down the road), events, helper classes, and any custom classes I need to share between different modules.  Think of this as a handy little crossroad between any parts of your application. 

Modules on the other hand are the bread and butter of this application.  Besides the shell, which holds the UI skeleton, and the infrastructure, which holds all those shared goodies, the modules are self-contained bundles of functionality to handle different concerns.  In my scenario, I need a way to look up and edit Jobs, Applicants, and Schedule interviews, a Notification module to handle telling the user when different things are happening (i.e., loading from database), and a Menu to control interaction and moving between different views.  All modules are going to follow the following pattern:

Module Layout

The module class will inherit from IModule and handle initialization and loading the correct view into the correct region, whereas the Views and ViewModels folders will contain paired Silverlight user controls and ViewModel class backings. 

WCF RIA Services

Since we've got all the projects in a single solution, we did not have to go the route of creating a WCR RIA Services Class Library.  Every module has it's WCF RIA link back to the main .Web project, so the single Linq-2-SQL (yes, I said Linq-2-SQL, but I'll soon be switching to OpenAccess due to the new visual designer) context I'm using there works nicely with the scope of my project.  If I were going for completely separating this project out and doing different, dynamically loaded elements, I'd probably go for the separate class library.  Hope that clears that up.  In the future though, I will be using that in a project that I've got in the "when I've got enough time to work on this" pipeline, so we'll get into that eventually- and hopefully when WCF RIA is in full release!

Why Not use Silverlight Navigation/Business Template?

The short answer- I'm a creature of habit, and having used Silverlight for a few years now, I'm used to doing lots of things manually. :)  Plus, starting with a blank slate of a project I'm able to set up things exactly as I want them to be.  In this case, rather than the navigation frame we would see in one of the templates, the MainRegion/ContentControl is working as our main navigation window.  In many cases I will use the Silverlight navigation template to start things off, however in this case I did not need those features so I opted out of using that.

Next time when I actually hit post #4, we're going to get into the modules and starting to get functionality into this application. 

About the Author

Evan Hutnick

works as a Developer Evangelist for Telerik specializing in Silverlight and WPF in addition to being a Microsoft MVP for Silverlight. After years as a development enthusiast in .Net technologies, he has been able to excel in XAML development helping to provide samples and expertise in these cutting edge technologies. You can find him on Twitter @EvanHutnick.

Related Posts


Comments are disabled in preview mode.