Quantcast
Channel: patterns & practices: Prism
Viewing all articles
Browse latest Browse all 1878

Commented Unassigned: How to share code in Prism for WPF and Silverlight? [10245]

$
0
0
Hello there,
I am facing an issue regarding code sharing in my Project where it follows Prism Pattern,
I have Linked one Silverlight and WPF modules, Where in the WPF Part I have some WPF Specific resource dictionary, and in Silverlight module with Silverlight dictionary. where those dictionaries contains Platform(WPF/Silverlight) specific templates and Style. The code for merging my dictionary look like the one given below for each platform.

```
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="SLTemplates.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
```
```
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="DesktopTemplates.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
```
We found that its not possible to have different code in a Shared File. because each and every update in a xaml file will update in both platform code, because the code is shared.
So we decided to Have the same name for Template files both Side, for accomplishing this task, We added __Templates.xaml__ in WPF , so it automatically shows up the link in Silverlight side. So we deleted the link for Templates.xaml in Silerlight and again added new file(Templates.xaml) in Silverlight. Now the Merge dictionary code look like this
```
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Templates.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
```
But the designer showing Exception for this user control in both Modules
screen shot for bug has been attached.

How can I get out of this issue?
Comments: ** Comment from web user: fmartinez **

Hi,

I'm not so sure that the approach you took is appropriate to achieve the functionality that you want. Merging __WPF__ and __Silverlight__ resources may not work correctly. Nevertheless, I believe that the problem you are facing could be related to the issue discussed in the following thread:
#
+ [WPF ResourceDictionary, MergedDictionaries mixed load from assembly and filesystem](http://social.msdn.microsoft.com/Forums/vstudio/en-US/8eb005af-f11b-4ce3-9357-a16d3a0eed84/wpf-resourcedictionary-mergeddictionaries-mixed-load-from-assembly-and-filesystem)

Hope this helps,

Federico Martinez
http://blogs.southworks.net/fmartinez


Viewing all articles
Browse latest Browse all 1878

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>