title: WPF reading Style from ResourceDictionary to Control in C# code
body: <p>I have code that looks like below:</p>
  
  <pre><code>ResourceDictionary res = (ResourceDictionary)Application.LoadComponent(new Uri("Style.xaml", UriKind.Relative));
  Style style = new Style();
  style.Resources = (Style)res["ComboBoxTextBox"];
  </code></pre>
  
  <p>VS2008 retuns an error: </p>
  
  <p>style.Resources = (<strong>Style</strong>)res["ComboBoxTextBox"];</p>
  
  <pre><code>Cannot implicitly convert type 'System.Windows.Style' to 'System.Windows.ResourceDictionary'
  </code></pre>
  
  <p>How I can properly assign a style from <code>ResourceDictionary</code> to control?</p>