title: How to get the value from a resource dictionary (XAML) in C#
body: <p>I'm working on a WPF-application in which the user can change the language (not the current culture!) at runtime.
  So i have multiple resource dictionaries of type XAML to which i added texts for making my WPF-app multilingual like that:</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"
                      xmlns:local="clr-namespace:Validation_DataAnnotations2.Resources"&gt;
      &lt;system:String x:Key="firstname"&gt;First name&lt;/system:String&gt;
      &lt;system:String x:Key="lastname"&gt;Last name&lt;/system:String&gt;
      &lt;system:String x:Key="mainwindowtitle"&gt;Validation with DataAnnotations&lt;/system:String&gt;
      &lt;system:String x:Key="german_language"&gt;German&lt;/system:String&gt;
      &lt;system:String x:Key="english_language"&gt;English&lt;/system:String&gt;
      &lt;system:String x:Key="insert_first_name"&gt;The first name has to be inserted&lt;/system:String&gt;
  &lt;/ResourceDictionary&gt;
  </code></pre>
  
  <p>The WPF-windows and controls are bound by the window resources.
  But i'm using DataAnnotations for validation.
  My first thought was to get the text to the key "insert_first_name" while the validation in my viewmodel.
  So i tried to get it by using this:</p>
  
  <pre><code>System.Windows.Application.Current.Resources.FindName("insert_first_name")
  </code></pre>
  
  <p>But when i use the method FindName, i get null.</p>
  
  <p>And when i try</p>
  
  <pre><code>System.Windows.Application.Current.Resources.Contains("insert_first_name")
  </code></pre>
  
  <p>i get "true", which means the key exists.</p>
  
  <p>How can i get the value to key?</p>
  
  <pre><code>protected void ValidateModel()
  {
      validationErrors.Clear();
      ICollection&lt;ValidationResult&gt; validationResults = new List&lt;ValidationResult&gt;();
      ValidationContext validationContext = new ValidationContext(personmodel, null, null);
      if (!Validator.TryValidateObject(personmodel, validationContext, validationResults, true))
      {
          foreach (ValidationResult validationResult in validationResults)
          {
              string property = validationResult.MemberNames.ElementAt(0);
              if (validationErrors.ContainsKey(property))
              {
                  validationErrors[property].Add(validationResult.ErrorMessage);
              }
              else
              {
                  validationErrors.Add(property, new List&lt;string&gt; { validationResult.ErrorMessage });
                  if (validationResult.ErrorMessage == "insert_first_name")
                  {
                      var text = System.Windows.Application.Current.Resources.FindName("insert_first_name");
                  }
              }
          }
      }
  
      // Raises the ErrorsChanged for all properties explicitly.
      RaiseErrorsChanged("FirstName");
      RaiseErrorsChanged("LastName");
  }
  </code></pre>