Reputation: 805
I have code that looks like below:
ResourceDictionary res = (ResourceDictionary)Application.LoadComponent(new Uri("Style.xaml", UriKind.Relative));
Style style = new Style();
style.Resources = (Style)res["ComboBoxTextBox"];
VS2008 retuns an error:
style.Resources = (Style)res["ComboBoxTextBox"];
Cannot implicitly convert type 'System.Windows.Style' to 'System.Windows.ResourceDictionary'
How I can properly assign a style from ResourceDictionary
to control?
Upvotes: 4
Views: 7256
Reputation: 8455
it should be as easy as
myControl.Style = (Style)res["ComboBoxTextBox"];
Upvotes: 5