Note that there are some explanatory texts on larger screens.

plurals
  1. POSharedResourceDictionary: edit resource in Blend
    text
    copied!<p>To optimize my application, I create a SharedResourceDictionary. With this, I save about 250 mb of memory at run-time, so it works well.</p> <p>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:</p> <p><img src="https://i.stack.imgur.com/RHdKW.png" alt="enter image description here"></p> <p>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...</p> <p>My SharedResourceDictionary is implemented like this (found on the web):</p> <pre><code>public class SharedResourceDictionary : ResourceDictionary { /// &lt;summary&gt; /// Internal cache of loaded dictionaries /// &lt;/summary&gt; public static Dictionary&lt;Uri, ResourceDictionary&gt; _sharedDictionaries = new Dictionary&lt;Uri, ResourceDictionary&gt;(); /// &lt;summary&gt; /// Local member of the source uri /// &lt;/summary&gt; private Uri _sourceUri; /// &lt;summary&gt; /// Gets or sets the uniform resource identifier (URI) to load resources from. /// &lt;/summary&gt; 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]); } } } /// &lt;summary&gt; /// Check if we are in Blend to prevent error /// &lt;/summary&gt; public bool IsInDesignMode { get { return (bool) DependencyPropertyDescriptor.FromProperty(DesignerProperties.IsInDesignModeProperty, typeof(DependencyObject)).Metadata.DefaultValue; } } } </code></pre> <p>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...</p> <p>Any clue will be appreciated. Thank you.</p> <p>EDIT:</p> <p>Doing this (SharedResourceDictionary), I also have an issue with static resource:</p> <pre><code>Provide value on 'System.Windows.Markup.StaticResourceHolder' threw an exception. </code></pre> <p>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.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload