WPF: Referencing app-wide resources in code-behind

Deniz Dogan picture Deniz Dogan · Feb 4, 2010 · Viewed 16.5k times · Source

I have made my own custom converter which given a string returns a Brush. Now I'm able to return constant brushes such as Brushes.Red etc., but I really want to use my own colors which I have defined in an application-wide resource.

How do I reference application-wide resources from my own custom converter class? I'd use FindResource but as I said, this is from my own converter class, not a window or control.

Answer

Reed Copsey picture Reed Copsey · Feb 4, 2010

If these are defined on your Application, you can use Application.Current.FindResource() to find them by name.