Issue Sharing Silverlight User Control in WPF

Topics: Prism v2 - Silverlight 3, Prism v2 - WPF 3.5
Oct 1, 2009 at 10:21 PM
Edited Oct 2, 2009 at 5:15 PM

I am trying to reuse a Silverlight User Control in a WPF application using "linked" files (i.e. Add as Link) and am running into an issue where code-behind is not able to resolve objects that exist in the markup.  I assumed this was due to the fact that my projects had different namespaces, so I modified the WPF project's namespace to match that of the Silverlight project, but I am still getting the same errors trying to reference the controls in the code-behind.

Any ideas on next steps? I have a complete solution I can share if somebody is interesting in seeing the code.

 

Oct 8, 2009 at 11:47 PM

Hi

Sharing views between Silverlight and WPF is not always viable, as there are some differences in the Markup between both technologies. That is why the project linker does not link this kind of files by default. My personal recommendation would be creating different views, one for each platform.

If for a particular reason you decide to share the views, you should make sure that only components and markup that is valid both in Silverlight and WPF composes the Views. You might find the information provided by the following links useful:

Please let me know if this helps.

Damian Schenkelman
http://blogs.southworks.net/dschenkelman

 

Oct 9, 2009 at 7:41 PM

That is unfortunately what I have decided to do.  I simply cannot figure out a way to share certain components, like the TabControl.  I’m not sure what the value of sharing code between Silverlight and WPF is if the views cannot be shared.  All of the presentation logic and business logic can still be shared, but that really has nothing to do with Silverlight or WPF.  That’s just standard VB.NET/C# code.

From: dschenkelman [mailto:notifications@codeplex.com]
Sent: Thursday, October 08, 2009 5:49 PM
To: Justin Storm
Subject: Re: Issue Sharing Silverlight User Control in WPF [CompositeWPF:70759]

From: dschenkelman

Hi

Sharing views between Silverlight and WPF is not always viable, as there are some differences in the Markup between both technologies. That is why the project linker does not link this kind of files by default. My personal recommendation would be creating different views, one for each platform.

If for a particular reason you decide to share the views, you should make sure that only components and markup that is valid both in Silverlight and WPF composes the Views. You might find the information provided by the following links useful:

Please let me know if this helps.

Damian Schenkelman
http://blogs.southworks.net/dschenkelman

Read the full discussion online.

To add a post to this discussion, reply to this email (CompositeWPF@discussions.codeplex.com)

To start a new discussion for this project, email CompositeWPF@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com