title: How to properly change a resource dictionary
body: <p>I am working on localizing a GUI in WPF. The code that I post here will be from a prototype because I am trying to make this question as simple as possible.</p>
  
  <p>I am using Resource Dictionaries to set the content of the strings in my window. I have two of them, one is German, and the other is English. </p>
  
  <p>German Resource Dictionary:</p>
  
  <pre><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                      xmlns:sys="clr-namespace:System;assembly=mscorlib"&gt;
  
      &lt;!-- The name of this ResourceDictionary. Should not be localized. --&gt;
      &lt;sys:String x:Key="ResourceDictionaryName" Localization.Comments="$Content(DoNotLocalize)"&gt;Loc-de-DE&lt;/sys:String&gt;
  
      &lt;!--- Button --&gt;
      &lt;sys:String x:Key="MainButton_Title"&gt;Hallo Welt!&lt;/sys:String&gt;
      &lt;sys:String x:Key="EnglishButton"&gt;Englisch&lt;/sys:String&gt;
      &lt;sys:String x:Key="GermanButton"&gt;Deutsch&lt;/sys:String&gt;
  
  &lt;/ResourceDictionary&gt;
  </code></pre>
  
  <p>English Resource Dictionary:</p>
  
  <pre><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                      xmlns:sys="clr-namespace:System;assembly=mscorlib"&gt;
  
      &lt;!-- The name of this ResourceDictionary. Should not be localized. --&gt;
      &lt;sys:String x:Key="ResourceDictionaryName" Localization.Comments="$Content(DoNotLocalize)"&gt;Loc-en-US&lt;/sys:String&gt;
  
      &lt;!--- Buttons --&gt;
      &lt;sys:String x:Key="MainButton_Title"&gt;Hello World!&lt;/sys:String&gt;
      &lt;sys:String x:Key="EnglishButton"&gt;English&lt;/sys:String&gt;
      &lt;sys:String x:Key="GermanButton"&gt;German&lt;/sys:String&gt;
  
  &lt;/ResourceDictionary&gt;
  </code></pre>
  
  <p>I also have dynamically set the content of my buttons in the XAML window:</p>
  
  <pre><code>&lt;Button Content="{DynamicResource MainButton_Title}" Margin="59,68,0,80" Name="button1" HorizontalAlignment="Left" Width="152" /&gt;
  &lt;Button Content="{DynamicResource EnglishButton}" Height="23" HorizontalAlignment="Right" Margin="0,83,87,0" Name="button2" VerticalAlignment="Top" Width="75" Click="button2_Click" /&gt;
  &lt;Button Content="{DynamicResource GermanButton}" Height="23" HorizontalAlignment="Right" Margin="0,0,87,90" Name="button3" VerticalAlignment="Bottom" Width="75" /&gt;
  </code></pre>
  
  <p>I want the language to change to English when I click the English button, and change to German when I click the German button. I have gotten this far, but what I don't know is the actual code that would be needed to tell the program to change it's Resource Dictionary. I'm guessing this would go in code-behind under the two button's click events, and might also have some code in the XAML window.</p>
  
  <p>These are the resources that I've used, but I am posting this question because the end solution is not clear enough to me:</p>
  
  <p>-<a href="http://www.wpfsharp.com/2012/01/27/how-to-change-language-at-run-time-in-wpf-with-loadable-resource-dictionaries-and-dynamicresource-binding/" rel="nofollow">http://www.wpfsharp.com/2012/01/27/how-to-change-language-at-run-time-in-wpf-with-loadable-resource-dictionaries-and-dynamicresource-binding/</a></p>
  
  <p>-<a href="http://msdn.microsoft.com/en-us/library/bb613547.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/bb613547.aspx</a></p>
  
  <p>-<a href="http://blogs.msdn.com/b/wpfsldesigner/archive/2010/06/03/creating-and-consuming-resource-dictionaries-in-wpf-and-silverlight.aspx" rel="nofollow">http://blogs.msdn.com/b/wpfsldesigner/archive/2010/06/03/creating-and-consuming-resource-dictionaries-in-wpf-and-silverlight.aspx</a></p>
  
  <p>Thank you for your help!</p>