In a Silverlight application we can define resources in the App.xaml and have access to them from any XAML document, without having to explicitly merge those resources.
Is there an equivalent solution for a class library? I created a separate resource dictionary in the class library, but I have to merge it as follows before I can use it.
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="MyResources.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
Is there a way to avoid this? It's rather tedious to do this in every XAML documents for globally used resources.
Global Resources. Global resources can be as easy as basic needs. Like food, clothing, shelter, leisure and cultural activities.
Resource files in ASP.NET have a . resx extension. Each localized resource file contains name/value pairs. You can use a text editor to customize a resource file's string values.
I was about to ask this same question. Unfortunately, what you've described is pretty close to what I've been able to come up with. In theory, it seems like you should be able to put these into the library's themes\generic.xaml file, but I haven't been able to make that work -- possibly I'm just doing something boneheaded. The best I've been able to do is just a slightly shorter variant of what you're doing, namely, to leave out 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'd love to have someone point me to a better solution :-).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With