resourcedictionary - WPF Using multiple Resource Dictionaries from multiple projects -


i have 2 class library projects: project a.themes project b.themes

project a.themes base themes project. project b.themes using a.themes , have new styles , of resources have keys defined in a.themes.

we want use 2 themes in our project, , if use resource defined in both of project want take resource b.themes.

this 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 same files:

brushes.xaml buttons.xaml checkbox.xaml 

we load them in bundle.xaml , adding 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 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. not takes resources b.themes , can't find out why. 2. if remove reference a.themes/bundle.xaml app.xaml project can't find resources a.themes though it's included in b.themes/bundle.xaml

note: have refernce a.themes project in b.themes , refernce a.themes , b.themes in main project

can please me understande going on here? thanks!

the loading order isn't quite expect. msdn:

resources in merged dictionary occupy location in resource lookup scope after scope of main resource dictionary merged into

https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/merged-resource-dictionaries

so dictionaries merge bundle.xaml of assembly loaded after other ones.

please refer following link more information , example of same behaviour: https://social.msdn.microsoft.com/forums/vstudio/en-us/3bea80f9-d1db-4cb7-ae7a-77a02eaf4ec9/resourcedictionary-load-order?forum=wpf


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -