Design-Time Dictionary

In my current VSTO project I need a design-time only resource dictionary. I found the following solution and modified it just a bit.

http://social.technet.microsoft.com/wiki/contents/articles/23287.trick-to-use-a-resourcedictionary-only-when-in-design-mode.aspx

I had some problems with the DesignMode detection in that sample so I used the version here…

https://bernhardelbl.wordpress.com/2011/06/16/howto-detecting-design-mode-in-wpf-asp-net-and-windows-forms-applications/

 


public class ResourceDictionary : System.Windows.ResourceDictionary
{
/// <summary>
/// Gets or sets the uniform resource identifier (URI) to load resources from.
/// </summary>
/// <returns>The source location of an external resource dictionary. </returns>
public new Uri Source
{
get
{
if (Util.DesignMode)
return base.Source;
else
return null;
}

set
{
if (Util.DesignMode)
{
base.Source = value;
}
}
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: