# Image Brush reference in a resource dictionary

**URL:** <https://forum.kirupa.com/t/image-brush-reference-in-a-resource-dictionary/290670>\
**Category:** programming\
**Created:** [June 18, 2009, 2:04am UTC](https://forum.kirupa.com/t/image-brush-reference-in-a-resource-dictionary/290670 "2009-06-18T02:04:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew24](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@Andrew24](https://forum.kirupa.com/u/Andrew24)\
**Post date:** [June 18, 2009, 2:04am UTC](https://forum.kirupa.com/t/image-brush-reference-in-a-resource-dictionary/290670/1 "2009-06-18T02:04:56Z")

</div>

I’m building a WPF app in Blend 3 which has an “indicator light” that I want to switch to an ON state when a game controller is detected. I am using a canvas object with the background set to an image brush resource defined in a resource dictionary.

```auto
<Canvas x:Name="ControllerIndicator" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="13" Height="13" Background="{DynamicResource Light_off}" Margin="0,0,303,35"/>

```

When my app detects the presence of a controller I want to programatically set the background of the canvas to another image brush resource I have defined in my resource dictionary; something like this:

(C#)

```auto
ControllerIndicator.Background = (ResourceDictionary.name???).Light_on;

```

Can I do it this way? If so, does anyone know the syntax?

Or, do I need to create the brush(s) dynamically in C#?

Any suggestions much appreciated.
