Silverlight & Composite Application Guidance (Prism): Spike published

Weeks ago we shipped the Composite Application Guidance for WPF and with the Prism team we started to spike around the migration of the Composite Application Library to Silverlight 2 Beta 2. The good news is that yesterday we published that spike. (A ‘spike’ is a small and quickly developed sample application in order to mitigate some risks).

After downloading and decompressing the latest change set of the source control, you will find a new folder named spikes that contains the Composite Application Library migrated to Silverlight. As you may imagine, there were many challenges that we had to address in order to make it “work”¬† (Rob Eisenberg wrote two articles describing differences between WPF and Silverlight that you might want to check: There’s some darkness in your silver light and Silverlight Problems That Affect Me).

Note: The migration is not complete, we used the spike to have a perspective of the challenges.



Module loading in Silverlight is very different from WPF, so this was a challenge. We continued spiking on different approaches, but those spikes are not uploaded to Codeplex yet.

Regarding the module enumerators, System.Configuration is not supported by Silverlight current version, so we are using a new XML file module enumerator (not published either).


In WPF, the RegionManager attached property value gets inherited by the elements in the visual tree. This cannot be done in Silverlight due to the lack of the FrameworkPropertyMetadataOptions.Inherits option. However, we have found a workaround for this issue.

If you want to declare regions in XAML, you have to create an application resource to store the RegionManager instance, so it can be used by the views. This can be done in the Bootstrapper, as shown in the code below:

protected override void ConfigureContainer()
   base.ConfigureContainer(); IRegionManager regionManager = Container.Resolve<IRegionManager>();
¬†¬ Application.Current.Resources.Add(“RegionManager”, regionManager);

And the view has to explicitly set the RegionManager attached property to the resource created previously.

<ItemsControl x:Name=”MainRegionControl” cal:RegionManager.RegionName=”MainRegion” cal:RegionManager.RegionManager=”{StaticResource RegionManager}” />


Events has been migrated successfully, however, the unit tests are still a challenge because of the differences in threading between Silverlight and WPF. One difference we found, is that if you are subscribing to an event using weak references, for this reason you can only use public methods as delegates (lambdas, anonymous delegates or private methods won’t work) because of security restrictions enforced by Silverlight.


As you might know, the support for commands is missing in Silverlight. This is really bad news, considering that big part of our guidance talk about using Commands for communication between the modules and from the view.

I’m not going into deep details on this because Julian Dominguez published a great post explaining how to use commands in Silverlight.


You can get the spike by downloading the latest change set of the CompositeWPF source control.


  • We didn’t ship the Unity Application Block, so I recommend you to see Michael Sync’s post in order to have Unity working on Silverlight.
  • In order to run the Unit tests, check Jeff Wilcox’post.

Feedback  / Contributions

Feel free to give us your feedback on the discussion board. If you want to contribute with the CompositeWPF project, check the CompositeWPF contrib. community site.



Leave a Reply