title: How to add an application wide resource dictionary in Silverlight 5?
body: <p>I've got a Silverlight 5 application that just refuses to accept anything in its Application.Resources tags:</p>
  
  <pre><code>&lt;Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           x:Class="My.Awesome.App"
           &gt;
  &lt;Application.Resources&gt;
      &lt;ResourceDictionary&gt;
          &lt;ResourceDictionary.MergedDictionaries&gt;
              &lt;ResourceDictionary Source="Assets/Styles.xaml"/&gt;
              &lt;ResourceDictionary&gt;
                  &lt;App:ApplicationResources x:Key="ApplicationResources" /&gt;
              &lt;/ResourceDictionary&gt;
          &lt;/ResourceDictionary.MergedDictionaries&gt;
      &lt;/ResourceDictionary&gt;
  &lt;/Application.Resources&gt;
  </code></pre>
  
  <p></p>
  
  <p>Neither the Styles.xaml nor the ApplicationResources are available to my controls.
  For example:</p>
  
  <pre><code>&lt;controls:ChildWindow
  x:Class="My.Awesome.ErrorWindow"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
  Title="{Binding Path=Errors.ErrorWindowTitle, Source={StaticResource ApplicationResources}}"
  Style="{StaticResource ErrorWindowStyle}"&gt;
  </code></pre>
  
  <p>That control will throw its bananas at runtime, but works <em>fine</em> in the Visual Studio editor (I can see the text coming from my ApplicationResources).
  The App:ApplicationResources from the App.xaml is as follow:</p>
  
  <pre><code>namespace My.Awesome
  {
      using System;
      using System.ComponentModel;
      using System.Globalization;
      using System.Windows.Browser;
  
      /// &lt;summary&gt;
      /// Wraps access to the strongly-typed resource classes so that you can bind control properties to resource strings in XAML.
      /// &lt;/summary&gt;
      public sealed class ApplicationResources
      {
          private static readonly ApplicationStrings applicationStrings = new ApplicationStrings();
          private static readonly ErrorResources errorResources = new ErrorResources();
  
          /// &lt;summary&gt;
          /// Gets the &lt;see cref="ApplicationStrings"/&gt;.
          /// &lt;/summary&gt;
          public ApplicationStrings Strings
          {
              get { return applicationStrings; }
          }
  
          /// &lt;summary&gt;
          /// Gets the &lt;see cref="ErrorResources"/&gt;.
          /// &lt;/summary&gt;
          public ErrorResources Errors
          {
              get { return errorResources; }
          }
      }
  }
  </code></pre>
  
  <p>And I have the corresponding ApplicationStrings.resx and ErrorResources.resx with the correct namespace specified (My.Awesome) and with the PublicResXFileCodeGenerator processor.</p>
  
  <p>I narrowed it down to the Application.Resources dictionary not working because if I do this in the code behind:</p>
  
  <pre><code>this.Resources.Add("ApplicationResources", new ApplicationResources());
  </code></pre>
  
  <p>and remove the reference to Styles, then the application runs.</p>
  
  <p>For reference I extracted the ErrorWindow.xaml, Styles.xaml and both .resx from a Silverlight Business Application template; it worked fine there I just can't figure out why it does not work in this app.</p>