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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:53:53+00:00 2026-05-11T16:53:53+00:00

WPF allows a control library to provide different resource dictionaries for different system themes,

  • 0

WPF allows a control library to provide different resource dictionaries for different system themes, essentially allowing an application to match the operating system’s selected visual theme (Aero, Luna, etc).

I’m wondering if I can include multiple theme resource dictionaries with my application and utilise some existing theme support within the framework. This should work for my own theme names, and ideally allow the user to change the theme and therefore the skinned appearance of the application at runtime. Even if this were only a config setting, it could still be interesting.

  • 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-11T16:53:53+00:00Added an answer on May 11, 2026 at 4:53 pm

    Here is a snippet of code that I used in my application that supported theming. In this example, I have two themes (Default and Classic XP). The theme resources are stored in the DefaultTheme.xaml and ClassicTheme.xaml respectively.

    This is the default code in my App.xaml

    <Application ...>
        <Application.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="ArtworkResources.xaml" />
                    <ResourceDictionary Source="DefaultTheme.xaml" />
                </ResourceDictionary.MergedDictionaries>
    
                <Style x:Key="SwooshButton" TargetType="ButtonBase">
                    <!-- style setters -->
                </Style>
    
                <!-- more global styles -->
            </ResourceDictionary>
        </Application.Resources>
    </Application>
    

    Then in the code behind of the App.xaml I have the following method to allow for changing the theme. Basically, what you do is clear the Resource Dictionaries and then reload the dictionary with the new theme.

        private Themes _currentTheme = Themes.Default;
        public Themes CurrentTheme
        {
            get { return _currentTheme; }
            set { _currentTheme = value; }
        }
    
        public void ChangeTheme(Themes theme)
        {
            if (theme != _currentTheme)
            {
                _currentTheme = theme;
                switch (theme)
                {
                    default:
                    case Themes.Default:
                        this.Resources.MergedDictionaries.Clear();
                        AddResourceDictionary("ArtworkResources.xaml");
                        AddResourceDictionary("DefaultTheme.xaml");
                        break;
                    case Themes.Classic:
                        this.Resources.MergedDictionaries.Clear();
                        AddResourceDictionary("ArtworkResources.xaml");
                        AddResourceDictionary("ClassicTheme.xaml");
                        break;
                }
            }
        }
    
        void AddResourceDictionary(string source)
        {
            ResourceDictionary resourceDictionary = Application.LoadComponent(new Uri(source, UriKind.Relative)) as ResourceDictionary;
            this.Resources.MergedDictionaries.Add(resourceDictionary);
        }
    

    What you’ll also need to keep in mind with this approach is that any styles that utilize a theme will need to have a dynamic resource. For example:

    <Window Background="{DynamicResource AppBackgroundColor}" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can't refer to mutables inside a closure, and that… May 12, 2026 at 3:10 pm
  • Editorial Team
    Editorial Team added an answer From the Oracle reference on add_months (http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14200/functions004.htm) If date is… May 12, 2026 at 3:10 pm
  • Editorial Team
    Editorial Team added an answer The reason is lazy loading. In order to make lazy… May 12, 2026 at 3:10 pm

Related Questions

If you have a WPF control library which you wanted to license to developers,
I have code that handles the LostFocus event of my controls. It validates the
WPF validation system performs intial validatation of an object (I mean - all fields
I have created a wysiwyg editor as a standard C# program using the windows

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.