How can I avoid Visual Studio designer errors when a WPF resource is defined in separate project?
I have three projects in a composite WPF application: the main appl
I just want to extend Simon D. answer. What he is proposing is the solution that i am using right now. I just wanted to share complete source code. It is from this Trick To Use A ResourceDictionary Only When In Design Mode source.
public class DesignTimeResourceDictionary : ResourceDictionary
{
///
/// Local field storing info about designtime source.
///
private string designTimeSource;
///
/// Gets or sets the design time source.
///
///
/// The design time source.
///
public string DesignTimeSource
{
get
{
return this.designTimeSource;
}
set
{
this.designTimeSource = value;
if ((bool)DesignerProperties.IsInDesignModeProperty.GetMetadata(typeof(DependencyObject)).DefaultValue)
{
base.Source = new Uri(designTimeSource);
}
}
}
///
/// Gets or sets the uniform resource identifier (URI) to load resources from.
///
/// The source location of an external resource dictionary.
public new Uri Source
{
get
{
throw new Exception("Use DesignTimeSource instead Source!");
}
set
{
throw new Exception("Use DesignTimeSource instead Source!");
}
}
}