开发者

WPF reading Style from ResourceDictionary to Control in C# code

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?


it should be as easy as

myControl.Style =  (Style)res["ComboBoxTextBox"];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜