Global Resources in the Class Library

In the Silverlight application, we can define resources in App.xaml and have access to them from any XAML document without the need to explicitly combine these resources.

Is there an equivalent solution for a class library? I created a separate resource dictionary in the class library, but before using it I must combine it as follows.

<UserControl.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="MyResources.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </UserControl.Resources> 

Is there any way to avoid this? It's pretty tedious to do this in every XAML document for public resources.

+6
resources silverlight
source share
1 answer

I was going to ask the same question. Unfortunately, what you described is pretty close to what I could come up with. Theoretically, it seems that you can put them in the \ generic.xaml library file in the library, but I could not do this work - maybe I'm just doing something unscrupulous. The best I could do is just a slightly shorter version of what you are doing, namely, to leave the MergedDictionaries syntax:

 <UserControl.Resources> <commonui:CommonStringsPublic x:Key="commonStrings" /> <ResourceDictionary Source="/Alanta.Client.UI.Common;component/CommonResources.xaml" x:Key="commonResources" /> </UserControl.Resources> 

I would like someone to point me to a better solution :-).

+1
source share

All Articles