title: Dynamically loading resource dictionary files to a wpf application gives an error
body: <p>I am trying to add a xaml resource file dynamically using the statement, </p>
  
  <pre><code>Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("resources/leaf_styles.xaml", UriKind.Relative) });
  </code></pre>
  
  <p>This is throwing an exception, <strong>Cannot locate resource 'resources/leaf_styles.xaml'.</strong></p>
  
  <p>I added the leaf_styles.xaml file to the project under resource folder and the BuildAction is set to "Content", CopyAlways is set to True. Still I get this error. Could some one help me out pointing whats wrong??</p>
  
  <p>Additional information - </p>
  
  <ul>
  <li><strong>I don't want to embed the xaml file as a resource</strong></li>
  <li><strong>The current project is a .net 3.5 class library project</strong></li>
  <li><strong>The above mergedictionary statement is written in a class belonging to the same project</strong></li>
  <li><strong>I also added the [assembly: AssemblyAssociatedContentFile("resources/leaf_styles.xaml")] manually once I figured that this is not working (for testing)</strong></li>
  </ul>
  
  <h2>Update</h2>
  
  <p>If I give it as an absolute location, it is working properly.   </p>
  
  <pre><code>Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri(@"D:\foo\trunk\bin\resources\leaf_styles.xaml", UriKind.Absolute) });
  </code></pre>