I'm trying to setup static resources for different states in my business entities. The idea being that I can use a value converter to take the business entity and return the corresponding background brush depending on an algorithm. I'd like the resources to be static so I can design them in the designer and switch them over manually to preview what it would look like during development, but be able to use them programatically.
The aim would be to have something along these lines:
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var data = value as DummyData;
if (data == null)
return null;
//Find resources
if (data.VarianceAmount >= 0)
return StaticResources.HighBackground;
else
return StaticResources.LowBackground;
}
If the static resources are declared in the page / control / framework element in the hierachy, how do I access it from inside the value converter? I've set my value converter to a DependencyObject, but i'm not sure how to navigate the hierachy from there.