How do I reuse Silverlight projects in WPF?

I would like to use the same project (class library) in Silverlight and WPF. So, I started working as a Silverlight class library.

But the problem is that some common classes (like Point, TouchAction) exist in different assemblies and the following error appears in the compiler when I add a reference to the Silverlight class library to my WPF project.

The "System.Windows.Point" type exists both in "c: \ Program Files \ Reference Assemblies \ Microsoft \ Framework \ Silverlight \ v4.0 \ System.Windows.dll" and in C: \ Program Files \ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.0 \ WindowsBase.dll '

Can anyone suggest a job?

+2


a source to share


1 answer


You can try Prism 2.0 :

Have two separate projects, but link files from one to the other. Portions specific to one platform can be separated by conditional compilation (#ifdef _SILVERLIGHT ... #elseif ... #end)



Check out the Multitasking Quickstart for more details (although all Quickstarts and reference implementations are both Silverlight and WPF versions, the multi-entry choice is the easiest if you only want to use cross-platform code). In the same project, you will find the Project Linker tool (although it only works in VS2008 as far as I know) that automatically keeps two or more projects in sync, adding links automatically when new items are added to the original project.

Hope this helps!

+2


a source







All Articles