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 290833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:02:02+00:00 2026-05-12T06:02:02+00:00

I have a BaseSkin and multiple UserSkins in a separate dll from my WPF

  • 0

I have a BaseSkin and multiple UserSkins in a separate dll from my WPF application.

Depending on who is using the application, the base skin and one of the user skins will be merged into a resource dictionary and loaded for the application to use.

What I’m aiming for is the ability to specify a style in a BaseSkin file, and then on a specific UserSkin file be able to override it, changing any properties I need to.

I know I can accomplish this by using the BasedOn attribute like this:

Base:

<Style x:Key="ButtonBg" TargetType="{x:Type Button}">
    <Setter Property="Background" Value="Green"/>
</Style>

User:

<Style x:Key="CustomButtonBg" TargetType="{x:Type Button}" BasedOn="{StaticResource ButtonBg}">
    <Setter Property="Background" Value="Blue"/>
</Style>

The problem is that now the elements have to have a Style of CustomButtonBg which may not actually be implemented. Is there any way to have both styles use the same key (ButtonBg), and when they’re merged have the application look for a style named ButtonBg in User first, and if one doesn’t exist, use the one in base?

I was thinking that if I could give the assembly name in the BasedOn attribute to point towards the BaseSkin file, I could avoid naming errors when I give them the same key, but I can’t find any way to do that. The other options are to just force an implementation of each style even if nothing gets changed, or check programatically in the skins, but those are last resorts.

  • 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-12T06:02:02+00:00Added an answer on May 12, 2026 at 6:02 am

    You could try to take advantage of the resource lookup logic. When WPF is trying to find a resource by the key, it first look in the current element’s ResourceDictionary, then its parent’s, then the parent of that, and so on.

    So since you said it is conditional to the user, that could be merged in the ResourceDictionary at the Window level while your original base is at the Application level.

    Edit: I have better information. From MSDN on Merged Dictionaries:

    Merged Dictionary Behavior

    Resources in a merged dictionary occupy a location in the resource lookup scope that is just after the scope of the main resource dictionary they are merged into. Although a resource key must be unique within any individual dictionary, a key can exist multiple times in a set of merged dictionaries. In this case, the resource that is returned will come from the last dictionary found sequentially in the MergedDictionaries collection. If the MergedDictionaries collection was defined in XAML, then the order of the merged dictionaries in the collection is the order of the elements as provided in the markup. If a key is defined in the primary dictionary and also in a dictionary that was merged, then the resource that is returned will come from the primary dictionary. These scoping rules apply equally for both static resource references and dynamic resource references.

    That means you can define your Base skin in a different ResourceDictionary and merge it into another ResourceDictionary. Have the User skin in the latter, and it will find it first, otherwise it will keep drilling down to the merged dictionary that contains Base. Each of your User dictionaries can merge the Base dictionary and you just load the User dictionary into the app instead of both separately.

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

Sidebar

Ask A Question

Stats

  • Questions 234k
  • Answers 234k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Table views with thousands of entries are fine, but you… May 13, 2026 at 6:03 am
  • Editorial Team
    Editorial Team added an answer For starters, you shouldn't use GAE with Python 2.6. Google… May 13, 2026 at 6:03 am
  • Editorial Team
    Editorial Team added an answer Apparently start is a pointer (or an array, which will… May 13, 2026 at 6:03 am

Related Questions

I have a web-service that I will be deploying to dev, staging and production.
I have a .Net desktop application with a TreeView as one of the UI
I have a Queue<T> object that I have initialised to a capacity of 2,
I have a complete XML document in a string and would like a Document

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.