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

  • SEARCH
  • Home
  • 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

Related Questions

I have a WPF application that allows users to create questions of all different
WPF doesn't provide the ability to have a window that allows resize but doesn't
If you have a WPF control library which you wanted to license to developers,
I need the DocumentViewer WPF control (for XPS files) in a Windows Form application.
I have a WPF application and I use external library for generating documents. This
The WPF ListView control allows to re-order of columns by drag and drop. Is
For you wpf silverlight people who are working with source control that allows merging.
Is there any file loader control in WPF which allows importing files during the
I am creating paint like application using WPF. Now i need to create control
WPF validation system performs intial validatation of an object (I mean - all fields

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.