I have two class Library projects:
Project A.Themes
Project B.Themes
Project A.Themes is my base Themes Project.
Project B.Themes using A.Themes and have new styles and some of the resources have keys that already defined in A.Themes.
We want to use this two themes in our Project, and if we use a resource that is defined in both of the project we want to take the resource from B.Themes.
This is our code:
A.Themes have few files of styles:
Brushes.xaml
Buttons.xaml
CheckBox.xaml
etc..
we load them in Bundle.Xaml:
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/A.Themes;component/Assets/Brushes.xaml"/>
<ResourceDictionary Source="pack://application:,,,/A.Themes;component/Assets/Buttons.xaml"/>
<ResourceDictionary Source="pack://application:,,,/A.Themes;component/Assets/CheckBox.xaml" />
</ResourceDictionary.MergedDictionaries>
B.Themes have the same Files:
Brushes.xaml
Buttons.xaml
CheckBox.xaml
we load them in Bundle.Xaml and adding the bundle of A.Themes:
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/A.Themes;component/Bundle.xaml"/>
<ResourceDictionary Source="pack://application:,,,/B.Themes;component/Assets/Brushes.xaml"/>
<ResourceDictionary Source="pack://application:,,,/B.Themes;component/Assets/Buttons.xaml"/>
<ResourceDictionary Source="pack://application:,,,/B.Themes;component/Assets/CheckBox.xaml" />
</ResourceDictionary.MergedDictionaries>
In our Project we load them in App.xaml:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/A.Themes;component/Bundle.xaml"/>
<ResourceDictionary Source="pack://application:,,,/B.Themes;component/Bundle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
the problems are:
1. it not always takes the resources from B.Themes and we can't find out why.
2. if i remove the reference to A.Themes/Bundle.xaml from app.xaml the project can't find resources from A.Themes even though it's included in B.Themes/Bundle.xaml
note:
we have refernce to A.Themes project in B.Themes
and refernce to A.Themes and B.Themes in main project
can someone please help me to understande what is going on here?
thanks!
See Question&Answers more detail:
os