title: How to change WPF Material Design Palette at runtime?
body: <p>I've recently "upgraded" a solution to a VS2017 and .NET Framework 4.6.1.</p>
  
  <p>I've also updated all of the NuGet packages to their latest versions.</p>
  
  <p>This question likely concerns one or more of the following packages (previous versions are in parenthesizes):</p>
  
  <pre><code>MahApps.Metro by Jan Karger et al. 1.6.5 (1.3.0-ALPHA016)
  
  MaterialDesignColors by James Willock 1.1.3 (1.1.2)
  
  MaterialDesignThemes by James Willock 2.5.0.1205 (1.1.0.234)
  
  MaterialDesignThemes.MahApps by James Willock 0.0.12 (0.0.3)
  </code></pre>
  
  <p>WPF related packages also being referenced include:</p>
  
  <pre><code>Extended.Wpf.Toolkit by Xceed 3.4.0 (2.6.0)
  
  ControlzEx by Jan Karger et al. 3.0.2.4 (none, new dependency of MahApps.Metro)
  </code></pre>
  
  <p>Prior to the updates, the following would change the UI color palette at runtime:</p>
  
  <pre><code>private void primaryPaletteComboBox_SelectedIndexChanged(object sender, EventArgs e)
  {
     paletteHelper.ReplacePrimaryColor(this.primaryPaletteComboBox.Text);
  }
  
  /* Where: */
  
  var paletteHelper = new MaterialDesignThemes.Wpf.PaletteHelper();
  
  this.primaryPaletteComboBox.Items.AddRange(new object[] {
      "Amber",
      "Blue",
      "BlueGrey",
      "Brown",
      "Cyan",
      "DeepOrange",
      "DeepPurple",
      "Green",
      "Grey",
      "Indigo",
      "LightBlue",
      "LightGreen",
      "Lime",
      "Orange",
      "Pink",
      "Purple",
      "Red",
      "Teal",
      "Yellow"});
  </code></pre>
  
  <p>...Super simple, super easy.</p>
  
  <p>After the updates, <code>ReplacePrimaryColor</code> throws the following exception:</p>
  
  <blockquote>
    <p>System.InvalidOperationException: 'Unable to safely determine a single
    resource definition for SecondaryAccentBrush.'</p>
  </blockquote>
  
  <p>Downgrading these packages to their previous versions cause other problems.</p>
  
  <p>How can I change the color palette at runtime in the most recent version of these packages?</p>
  
  <p>I would like to do this by simply using the color palette name that the user selects from a ComboBox.</p>
  
  <p>Obviously <code>SecondaryAccentBrush</code> is a problem. </p>
  
  <p>Does anyone know what changed in the last few years?</p>
  
  <p>This should be easy, but Google doesn't give me anything useful. Maybe I'm not asking the right question. </p>
  
  <p>PaletteHelper now provides a <code>ReplacePalette(Palette palette)</code> method that looks promising, perhaps there is a way to instantiate a Palette object by using the name of a predefined resource? </p>
  
  <p>I would rather go to the dentist and proctologist at the same time, than to screw around with XAML resource definitions. </p>