title: How to retrieve string from resource file in codebehind?
body: <p>I have a Resource Dectionary in main project.</p>
  
  <pre><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                  xmlns:system="clr-namespace:System;assembly=mscorlib"&gt;
  
  &lt;system:String x:Key="ToolbarNewButton" &gt;Add&lt;/system:String&gt;
  &lt;system:String x:Key="localizedMessage" &gt;Delete Item&lt;/system:String&gt;
  </code></pre>
  
  <p>and a class library that add it to main project. I use DynamicResource in it.</p>
  
  <pre><code> &lt;Label Content="{DynamicResource ToolbarNewButton}"  Foreground="{DynamicResource InputFontColor}"/&gt;
  </code></pre>
  
  <p>I want to retrieve string from resource file in codebehind. I use this code but get <strong>ResourceReferenceKeyNotFoundException</strong> </p>
  
  <pre><code>string localizedMessage = (string)Application.Current.Resources["localizedMessage"];
  </code></pre>