Tarun
Tarun

Reputation: 393

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 Class 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?

Upvotes: 0

Views: 1209

Answers (2)

Vinit Sankhe
Vinit Sankhe

Reputation: 19895

Refer that resource dictionary file (.xaml) explicitly using MergedDictionaries in your WPF Window / Page / UserControl's XAML.

Upvotes: 1

Kent Boogaart
Kent Boogaart

Reputation: 178790

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.

Upvotes: 2

Related Questions