I'm creating triggers in code behind and I'm attempting to bind the value of a setter to a dynamic resource created in the code behind as well so I can update the resource whenever and still have the value of the setter updated. I'm as far as this
SolidColorBrush brush = Brushes.Red;
Resources.Add("NewBrush",brush);
Setter setter = new Setter();
setter.Property = Control.BackgroundProperty;
but I'm unsure how to bind the value of the setter to the Dynamic Resource created. I can't simply create the resource in XAML because the resource needs to be created dynamically. How do I bind the value of the Setter to the dynamic resource so changing the resource will alter the value of the setter.
A little more information to clarify. This is all done in code behind because everything is generated dynamically. Triggers, setters, formatting, controls are all being created based off an XML structure.
I can't simply create the resource in XAML because the resource needs to be created dynamically
- That's no reason not to define theSetter
in XAML. – Martin