Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
675
Cell background coloring
posted

I know this has been asked a million times, but I haven't been piece together anything that works.

- Coloring cell by cell, not per row

- Fields created in code

- Colors dynamic

A selector didn't seem to do the trick, because simply setting the style erases all other things I set when building the fields.

I've done other binding through triggers, but that was for a single state (bold/not bold), something like

 

 

 

 

 

 

 

 

 

 

 

var trig = new DataTrigger();

trig.Binding =

new Binding("DataItem.Changed");

trig.Value =

false;

trig.Setters.Add(

new Setter(XamNumericEditor.FontWeightProperty, FontWeights.Normal));

style.Triggers.Add(trig);

trig =

new DataTrigger();

trig.Binding =

new Binding("DataItem.Changed");

trig.Value =

true;

trig.Setters.Add(

new Setter(XamNumericEditor.FontWeightProperty, FontWeights.Bold));

 

style.Triggers.Add(trig);

What I'd like to do is bind to a property on my DataItem that returns a Brush, or should I create a bunch of triggers on a, say, int property with individual Brush values?

Or does anyone have a better idea?