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

Created 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?

Viewing all articles
Browse latest Browse all 1878

Trending Articles