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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:55:29+00:00 2026-06-07T04:55:29+00:00

To optimize my application, I create a SharedResourceDictionary. With this, I save about 250

  • 0

To optimize my application, I create a SharedResourceDictionary. With this, I save about 250 mb of memory at run-time, so it works well.

My problem is in design-time, in Blend 4, I have no more access to my resource. To modify a template (witch is in my resource file), I usually right click on my control and I choose Edit Template –> Edit Current, like in this image:

enter image description here

I need to modify my template that way, it’s 100x faster then to go in my resource file and find the good one… I have A LOT of resources…

My SharedResourceDictionary is implemented like this (found on the web):

public class SharedResourceDictionary : ResourceDictionary
{
    /// <summary>
    /// Internal cache of loaded dictionaries 
    /// </summary>
    public static Dictionary<Uri, ResourceDictionary> _sharedDictionaries =
        new Dictionary<Uri, ResourceDictionary>();

    /// <summary>
    /// Local member of the source uri
    /// </summary>
    private Uri _sourceUri;

    /// <summary>
    /// Gets or sets the uniform resource identifier (URI) to load resources from.
    /// </summary>
    public new Uri Source
    {
        get
        {
            if (IsInDesignMode)
                return base.Source;

            return _sourceUri;
        }
        set
        {
            _sourceUri = value;

            if (!_sharedDictionaries.ContainsKey(value))
            {
                // If the dictionary is not yet loaded, load it by setting
                // the source of the base class
                base.Source = value;

                // add it to the cache
                _sharedDictionaries.Add(value, this);
            }
            else
            {
                // If the dictionary is already loaded, get it from the cache
                MergedDictionaries.Add(_sharedDictionaries[value]);
            }
        }
    }

    /// <summary>
    /// Check if we are in Blend to prevent error
    /// </summary>
    public bool IsInDesignMode
    {
        get
        {
            return
            (bool)
            DependencyPropertyDescriptor.FromProperty(DesignerProperties.IsInDesignModeProperty,
            typeof(DependencyObject)).Metadata.DefaultValue;
        }
    }
}

Someone have an idea if there is a solution for this? I really want to keep this shared dictionary due to the memory improvement, but I also want to modify my resource easily…

Any clue will be appreciated. Thank you.

EDIT:

Doing this (SharedResourceDictionary), I also have an issue with static resource:

Provide value on 'System.Windows.Markup.StaticResourceHolder' threw an exception.

And when I change them to dynamic resource it works, or if I change the SharedResourceDictionary by a simple ResourceDictionary it also works. The project can compile but I cannot edit the resource without a modification as I said.

  • 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-07T04:55:31+00:00Added an answer on June 7, 2026 at 4:55 am

    Are you compiling for .NET 4?

    You might be hitting the bug where it fails to scan your ResourceDictionaries properly.

    There’s talk that you have to add your ResourceDictionaries at the the App.xaml level (in Application.Resources) level, and add a dummy default style.

    This might not work for you as you seem to be adding your resources in your control.

    http://blogs.windowsclient.net/rob_relyea/archive/2010/04/26/my-staticresource-reference-worked-differently-with-wpf-4-rc-than-it-does-with-wpf-4-rtm.aspx

    Adding a Merged Dictionary to a Merged Dictionary

    Trouble referencing a Resource Dictionary that contains a Merged Dictionary

    http://connect.microsoft.com/VisualStudio/feedback/details/553528/defaultstylekey-style-not-found-in-inner-mergeddictionaries

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

Sidebar

Related Questions

I was given this WPF application, when I tried to run the program in
I'm writing HFT trading application. I'm trying to optimize my application to minimize number
I am trying to optimize this query as good as possible,but still i am
Do browser vendors optimize against jQuery? I know this sounds absurd anti-standard, but I
I'm trying to figure out if this is relatively well-performing T-SQL (this is SQL
I am building an WPF Prism MVVM application. This application will contain a lot
I have a Silverlight application which loads about 2000 objects of half a dozen
Trying to create a an image acquiring application optimized for a fast scanner (which
I am trying to optimize the code for an application we are currently developping.
I'm trying to optimize my application and load certain things into the Rails cache

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.