Share a control or module between Web Project and Windows Project

Topics: Prism v2 - Silverlight 2, Prism v2 - WPF 3.5
Apr 21, 2009 at 8:25 AM
There some issues to adapt the Prism 2.0 in our project.

The main issue is sharing some control or panel ( is this Module in Prism ?) both WPF application and Silverlight Application (ASP.NET Web Project).

I have seen the sample code "StockTrader" that show us how to share a same View part and logic both WPF and Silverlight.
But The sample need to modify some code to share the view part in the Silverlight project.

Is there a way to use exactly same view or module in both WPF and Silverlight?

I know the WPF and Silverlight use another runtime.
But What if I make a silverlight control and use this silverlight control in WPF, is the possible?
or is there another way to solve this problem?
Apr 21, 2009 at 6:50 PM

Hi,

 

A control or panel in Prism would usually be a view. A view is a UI element that composes a Composite Application and modules usually have one or more views. For a detailed description about modules and views you can check:

·         Modularity (design concept)

·         UI Composition (design concept)

 

Regarding the sharing of a view, there is no way to make this happen because as you said WPF and Silverlight use different runtimes. The reference implementation uses the Project Linker: Synchronization Tool to share files. The tool does not share files that fulfill at least one of the following conditions:

·         Files that have the file name suffixes .Silverlight.cs or .WPF.cs

·         Files that reside in Silverlight or Desktop folders

·         XAML files

 

Therefore, you should be able to share almost entire modules, except their view. This of course will also depend in the content of the classes you share.

Because of the differences between the XAML in Silverlight and WPF, the following elements are harder to reuse:

·         Complex views (XAML)

·         Controls

·         Styling

·         Animation

 

For a detailed description about sharing code between Silverlight and desktop applications you can check:

·         Multi-Targeting (design concept)

·         Multi-Targeting QuickStart

 

Please let me know if this helps.

 

Damian Schenkelman

http://blogs.southworks.net/dschenkelman