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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:56:35+00:00 2026-06-11T06:56:35+00:00

I am working on an app that uses a resource dictionary for styling. I

  • 0

I am working on an app that uses a resource dictionary for styling. I have to make a change that will enable a config setting to change the dictionary being used.

I have three dictionaries: Original.xaml, Neon.xaml & Graphite.xaml.

App.xaml:

 <ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Resources/Original.xaml"/>
    </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

I can change the dictionary being used by calling:

private void DynamicLoadStyles(string StyleToUse)
{
    string fileName = "C:\\Data\\Projects\\MyApp\\MyApp\\Resources\\" +
        StyleToUse + ".xaml";
    using (FileStream fs = new FileStream(fileName, FileMode.Open))
    {
        ResourceDictionary dic = (ResourceDictionary)XamlReader.Load(fs);
        Resources.MergedDictionaries.Clear();
        Resources.MergedDictionaries.Add(dic);
    }
 }

All works as expect (however I am not sure if this is the correct way to do it). The problem is I would rather embed the files and not have to load them from an external file.

I have searched for info to help but cannot find what I am looking for. That said I am new to WPF (3 weeks) and not really sure what I am doing yet.

Any help would be greatly appreciated.

  • 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-06-11T06:56:36+00:00Added an answer on June 11, 2026 at 6:56 am

    I don’t really like to answer my own question as it suggests I shouldn’t have asked in the first place. But I have solved the problem using ….

        private void LoadDynamicResource(String StyleToUse)
        {
    
            ResourceDictionary dic = new ResourceDictionary { Source = new Uri(StyleToUse, UriKind.Relative) };
            Resources.MergedDictionaries.Clear();
            Resources.MergedDictionaries.Add(dic);
    
        }
    

    I would be interested in opinions on this though.

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

Sidebar

Related Questions

I have a jqueryMobile app that uses google maps api and is working properly
I used to have a small chat app(which was almost working), that uses PHP,
Using Visual Studio 2008 and VB.Net: I have a working web app that uses
I have a working rails app that uses imagemagick commands on my local mac
For the past few weeks I have been working on an app that uses
Newbie question... I have a working console app that uses a shared unit I
I have a working app that uses a bunch of PNG files; it was
I am working on an app that uses a custom file type, I've figured
I'm working on a Node app that uses Express and SocketIO. I want to
I'm working on a small app that uses the Facebook API. What I want

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.