title: DataGrid - Change Column Header at Runtime
body: <p>I am currently working on a multilingual app where the interface text can be swapped at runtime based on the language that is selected by the user. I am using DynamicResources defined in a ResourceDictionary and swapping the dictionary file when the language is changed. This works great for everything except for the DataGrid's Column Header property. I know that the DataGrid column is not part of the Visual Tree and have used proxies for binding to properties in my VM in the past however, in this case there is no binding to the VM. How can I go about updating the column headers when the ResourceDictionary is swapped?  </p>
  
  <p>My method for swapping dictionaries is below. This resides in the Application.xaml.vb and is called upon app startup passing a string saved in MySettings.Default. This is also called using a messenger from a property in a VM that is bound to a ComboBoxSelectedIndex.</p>
  
  <pre><code>Private Sub SetLanguage(ByVal language As String)
      Dim dic As ResourceDictionary = Nothing
      Dim langFile As String = Environment.CurrentDirectory &amp; "\Languages\" &amp; language &amp; ".xaml"
      If File.Exists(langFile) Then
          Using fs As FileStream = New FileStream(langFile, FileMode.Open)
              dic = CType(XamlReader.Load(fs), ResourceDictionary)
              If LanguageCount &gt; 0 Then
                      Resources.MergedDictionaries.RemoveAt(Resources.MergedDictionaries.Count - 1)
              End If
              Resources.MergedDictionaries.Add(dic)
          End Using
      End If
      LanguageCount += 1
  End Sub
  </code></pre>
  
  <p><strong>The related DataGrid xaml</strong></p>
  
  <pre><code>&lt;DataGridTextColumn Header="{DynamicResource G_Spec}" ... /&gt;
  </code></pre>
  
  <p><strong>The ResourceDictionary entry</strong></p>
  
  <pre><code>&lt;system:String x:Key="G_Spec"&gt;Spec:&lt;/system:String&gt;
  </code></pre>