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

WPF doesn't provide the ability to have a window that allows resize but doesn't
WPF validation system performs intial validatation of an object (I mean - all fields
Using WPF, I have a TreeView control that I want to set its ItemTemplate
Is it possible to create a WPF Window control at runtime? I'm thinking of
I have a WPF window that manages sets of configurations and it allows users
I’m having issues with a WPF Expander that I have in a user control
To translate my WPF application I use a Markup extension which returns a Binding
I have a usercontrol in my wpf application which is causing a stackoverflowexception to
WPF, Browserlike app. I got one page containing a ListView. After calling a PageFunction
WPF's view model oriented way of doing things makes it very tempting to just

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.