Why are styles not getting applied on wpf controls?
I have developed a WPF application.
I have a one resource dictionary file in which I have written styles for the wpf controls such as button or label. I need to use this wpf application in windows form application so that I have changed the output type of wpf application to Cl开发者_StackOverflow中文版ass Library and referred it in the windows application.
It referred in the windows application with no errors and I can see the wpf xaml windows, but now the styles are not getting applied to the controls in windows application.
Any hint?
Presumably, your resource dictionary was referenced by your App.xaml. From memory, when you host WPF content in a Winforms app, the resource resolution process does not even look at your Application object. Therefore, you will need to import your resource dictionary into the views themselves so that your styles resolve.
Refer that resource dictionary file (.xaml) explicitly using MergedDictionaries in your WPF Window / Page / UserControl's XAML.
精彩评论