How to set a relative path/Uri in ResourceDictionary's source

WPFKK picture WPFKK · Aug 22, 2012 · Viewed 35k times · Source

I am trying to refer to a MergedDictionaries.SharedStyles project which has all Styles that has to be used allover application. So here i have different styles under different folders as Resource Dictionaries. so finally i have Merged them into AllSharedStyles.xaml and have that at Styles project level.

Now I have another ResourceDictionary at Solution level <> which refers to AllSharedStyles.xaml resource dictionary <<>>. This ResourceDictionary is added as a link to all my modules in solution.

Issue here is In my SharedResourceDictionary i am having following MergedDictionaries

<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="/MergedDictionaries.SharedStyles;component/AllSharedStyles.xaml" />
    <ResourceDictionary Source="/View/LocalResource.xaml" /> 
</ResourceDictionary.MergedDictionaries>

Project architecture

I have refered to common Resource first then my local inorder to override(only if required) any styles specific to module.

Now when i run the application it complains

'Set property 'System.Windows.ResourceDictionary.Source' threw an exception.' Line number '5' and line position '10'.

Thats the error message.

With my understanding it is looking for proper reference. I also tried using Pack URL ref: Pack URLss. Here is the pack url:

 <ResourceDictionary Source="pack://application:,,,/MergedResourceDictionaries.Styles;component/component/AllSharedStyles.xaml" />

So any suggestions on How to have a relative path here????

Sorry for my description/projection of problem

Answer

WPFKK picture WPFKK · Oct 31, 2012

Finally worked out solution:

<ResourceDictionary Source="../SharedResourceDictionary.xaml" /> 

Changed it to relative path and given root path.