I have two libraries and a single application assembly project layout and I'm wondering how can I reference styles by their key in one of my libraries that's defined in the other.
My solution layout:
- WpfControls.dll - Holds generic reusable controls such as a WPF based NumericUpDown control as well as other basic controls and some styles as well that I would like to make reusable. For the sake of the example lets say my style key here is defined as MyButtonStyle.
- SpecializedControls.dll - Holds controls that are specialized to our application such as custom composite controls and UserControls in WPF. This is where I'd like to reference the MyButtonStyle style defined in WpfControls.dll assembly.
- Application.exe - This assembly uses controls defined in the SpecializedControls.dll assembly.
I've seen some examples explaining how to do this with a simple single control library and application assembly but in my case I have two assemblies and an application. So in other words in my case I don't have an App.xaml in my second control library where I could use the MergeDictionaries concept. I'm pretty sure if I wanted to I could put a MergedDictionaries reference directly in each controls XAML file to merge all of Generic.xaml defined in WpfControls.dll assembly but my guess is that this would result in styles being redundantly merged into various places in my SpecializedControls assembly which doesn't seem like the best solution. To make matters worse, these dictionaries might also be merged into Application.exe as well, does this begin to bloat my application at runtime?
Can anybody clarify what the recommended or best approach for sharing such styles with the least amount of programtic and resource overhead.
Update: After a bit more testing it appears that I'm having trouble referencing any resource defined within Generic.xaml by it's key even within the same assembly. There may be something totally wrong about how I'm understanding how resource keys work so I'll have to a bit more research as well as looking into ComponentResourceKey. If anybody has any hints or suggestions please help.