Prism to Silverlight

Summary of Changes

The first roadblock in porting to Silverlight is the fact that a dependency injection system currently does not exist for the platform. As such, a lightweight DI system called DILight was created. It is included under the Framework folder and it's very similar to Unity. Please be aware that DILight is new and still needs testing. Also be aware that if Unity is ported to Silverlight our intent is to migrate away from DILight.

The next major change from the desktop stems from the fact that Silverlight does not support commands. Currently all of the command infrastructure from Prism has been left out. We are looking at ways of extending the Silverlight control model to support commands in a limited fashion.

File-Level Change Log

Changes Required for Drop 9158

4/18/2008, 1:19 PM

File(s)
Prism\ActiveAwareCompositeCommand.cs
Prism\ActiveAwareDelegateCommand.cs
Prism\CompositeCommand.cs
Prism\DelegateCommand.cs

Issue
Silverlight does not have the concept of a command and the ICommand interface does not exist.

Resolution
All Prism command classes have been removed.


File(s)
Prism\RegionManager.cs (Line 31)

Notes
For RegionProperty dependency property: PropertyMetadata does not exist and cannot be used as the 4th parameter. However, OnSetRegionCallback can be specified directly.

Resolution
OnSetRegionCallback specified as 4th parameter rather than a new PropertyMetadata.


File(s)
Prism\Regions\ItemsControlRegion.cs (Lines 109, 129)

Notes
Silverlight does not have the concept of a Selector. ListBox, for example, implements it's own SelectedItem property.

Resolution
Any reference to Selector was changed to ListBox. This is not a reliable solution. If the Silverlight team does not implement selectors we can only hope a more common SelectedItemProperty and / or selection interface is created. I have submitted this to the Silverlight discussion groups.

Last edited Apr 21, 2008 at 5:12 PM by jaredbienz, version 9

Comments

neurosoup Jul 25, 2008 at 4:40 PM 
I know DILight is a temporary solution but i would like to point out a bug (i think it is).
in the RegisterInstance(Type t, string name, object instance) method the line :

namedInstances[t][name] = instance;

should be

namedInstances[t] = new Dictionary<string,object>();
namedInstances[t][name] = instance;



// Register
namedInstances[t] = new Dictionary<string,object>();
namedInstances[t][name] = instance;

neurosoup Jul 23, 2008 at 1:59 PM 
ItemsControlRegion is not for ItemsControl derived controls since it uses ListBox dependency properties (SelectedItem for example). I had to write a TabControlRegionManager. How about rename ItemsControlRegion to ListBoxRegion or make more generic region manager for ItemsControl ?

dcuccia Jul 12, 2008 at 4:45 AM 
Ninject 1.0 (http://ninject.org/) supports Silverlight 2 Beta 2 - maybe an alternative to DILite?