Xaml: C # How to keep the style consistent

I am working on a semi-large window using wpf and C # in VS 2010. While working with xaml, I added a tag so that all buttons and datagrids are written the same. I copied and pasted this block into several of my .xaml files, and it works fine. Of course, the problem that I am currently facing is that I added and changed the style several times.

What is the best way to keep the style consistent with my different windows? Is this a subclass using Resource.resx or otherwise?

0
source share
2 answers

If you define a style at the application level ResourceDictionary (App.xaml), then it will be automatically inherited by your other Windows / Controls XAML files.

+6
source

Yes, if you have to create a new Resource.xaml file and then add it to your Application.xaml file:

<Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Resources.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> 

then you should be able to reference styles in Resource.xaml from all windows of your application.

+1
source

Source: https://habr.com/ru/post/1394509/


All Articles