Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 640585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:58:11+00:00 2026-05-13T20:58:11+00:00

I have two libraries and a single application assembly project layout and I’m wondering

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T20:58:11+00:00Added an answer on May 13, 2026 at 8:58 pm

    Resource lookup in WPF works in a hierarchy: up the logical tree, then application resources, theme resources and finally system resources.

    Theme resources can usually be accessed only implicitly (even within the assembly they are defined). This is relevant only for Styles, where the TargetType can be used as the implicit key.

    To accomplish what you’re trying to do, there are two options:

    • Use a ComponentResourceKey. This is a special resource key which allows referencing resources from other assemblies. For example, you can define a brush in WpfControls theme dictionary:

      <LinearGradientBrush x:Key="{ComponentResourceKey TypeInTargetAssembly=local:MyClass, ResourceId=MyBrush}">
          <GradientStop Color="Red" />
          <GradientStop Color="Blue" Offset="1" />
      </LinearGradientBrush>
      

      And then you can reference it in SpecializedControls:

      <UserControl Background="{StaticResource {ComponentResourceKey TypeInTargetAssembly=wpfControls:MyClass, ResourceId=MyBrush}}" />
      
    • Use MergedDictionaries to import a dictionary into the application resources. You can do this in the Application assembly, and when the application loads, even controls that are in SpecializedControls would be able to use these resources. You will have a problem with the design-time experience in this scenario, which you can solve by putting a fake App.xaml in SpecializedControls, that would also contain a reference to the dictionary.

    Hope this helps,

    Aelij.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.