Resource Dictionary as a linked file

Resource Dictionary

11/03/2010 10:56 AM |

I have two different projects. I linked the resource directory by adding an existing add element as a reference.

Silverlight does not see the resource dictionary if it is a linked file and gives me an error out of range.

Any work on this or any better way to use the same file in two projects?

0
silverlight
source share
2 answers

I would refer to the assembly, which usually has a resource dictionary (do not add it as a link), and then bring it to the application using the Unified Dictionaries . You can specify a resource dictionary in an external assembly to be combined into current application or page dictionaries.

<Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/SharedThemeAssembly;component/MyStyles.xaml"/> ...other ResourceDictionaries to merge in... </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> 

I answered a similar SO question here: Silverlight: multiple projects use the same style files

0
source share

If the share is located between the Silverlight and the WPF project, it’s easier for me to put the file in the silverlight project and link it to the WPF project than to do the opposite.

In other words, the file is moved to the silverlight project, not the WPF project, and then β€œlinked” to the WPF project.

Also remember when a file is referencing WPF as it is linked, you need to change the link url as if it is in the root, for example:

 <ResourceDictionary Source="pack://application:,,,/AssemblyName;component/DictionaryName.xaml" /> 

Deleting the folder above works, the uri below does NOT work:

 <ResourceDictionary Source="pack://application:,,,/AssemblyName;component/FOLDER/DictionaryName.xaml" /> 
0
source share

All Articles