Building an Enterprise Composite Silverlight Application

UPDATE: This sample has been updated for Silverlight 2.0 RTW.

 

A few weeks ago the Composite WPF (Prism) team put out a release which contained a port of the library for Silverlight. I looked at the reference applications and decided that I wanted to put together a sample that would help me figure out how to structure an "enterprise" application.

After looking at the reference applications that were provided with Composite WPF, I had a few questions:

  1. How do I structure my application shell?
  2. How do I host multiple modules?
  3. How do I navigate between multiple "screens"?
  4. How would I show dialogs?
  5. How do I communicate between views?

You know, I am just guessing here, but I think I can structure this stuff just about any way I want. Composite WPF is just guidance after all. However, I think what I have done is in the spirit of the guidance. However, if I am off base, I am hoping some of you will let me know what I can do to improve the design.

With that said, you can look at my sample here.

Now, the first thing many of you will say is,"Wow, that sucks!" True, the demo is nothing special from a visual perspective. And let me tell you, my layout skillz are lam3!

I would say that anything worth looking at is in the code. The purpose of this exercise was really just to see how I could put together a composite application. I am interested in application structure from a UI perspective, not visual appeal. Also, this is a work in progress. I will be doing more with this in the near future.

My design relies heavily on inversion of control (as does the guidance itself) and I am using Model-View-Presenter (MVP). Rather, I should say View-Presenter. My sample does not have any need for a model...yet. Again, I wanted to focus on building multiple composite views and connecting them together within the context of an application shell.

The sample has two modules, Alpha and Beta. Each provides "menu" items which are added to the application shell when the module loads. These commands can be invoked to display several different views.

The Alpha modules contains many points of interest including the use of WPF commands (or port of them I should say), wiring up MVP, scoped regions, and using the event aggregator. I know the code is primitive. There are several areas that are ripe for refactoring. There is a bug with one of the views that uses the event aggregator. It never unsubscribes from the event.

Also, the modules are not dynamically loaded; they are directly referenced by the primary Silverlight assembly. That's not the greatest thing, but StaticModuleEnumerator is the only module enumerator that has been ported at the time of this writing.

But with that said, I still like where the sample is headed. Over time it will get better, I'm sure.

You can download the code here.

Related posts

Comments

August 24. 2008 22:28 Sergio Ferreira

Sergio Ferreira
Hi, I have been using your sample, it works well, jp.hamilton thanks, that's great work.

October 8. 2008 17:32 Michael Sync

Michael Sync
Did you register the region in XAML or from code?

I tried registering the main region but i found that it's not working.

October 8. 2008 23:58 JP

JP
@Michael

I honestly can't remember. The code is here:
www.jphamilton.net/.../CompositeSilverlight.zip

I want to say that the regions are defined in Shell.xaml.

November 7. 2008 00:18 Donn

Donn
JP - Just thought I'd let you know that your example demo page (www.jphamilton.net/.../CompositeSilverlight.html) will not play with the RTW of Silverlight.

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

November 21. 2008 13:09