angelok

Here's a design question. I came across it when I was trying to flag a value. In my case, the user could select a normal or abnormal value, and I would paint the selection red or green. Both were acceptable answers. There are 2 ways I did this in prototyping, and I'm not sure which is best.

#1. Create an IsNormal property, bind the Background to that and use a IValueConverter to convert that to a brush.

#2 Create an IsNormal property, and trigger the background to change to a brush.

Solution 2 allows me to add the brush to the default style of the custom control, whereas #1 requires it in code (the IValueConverter). I see that difference, but is there a pragmatic reason to use one of the other



Re: Windows Presentation Foundation (WPF) Binding vs Triggers

Drew Marsh

I would personally lean to #2 because a) it required no code (as you pointed out) and b) the trigger can change so much more than just the background property if the designer wanted to.

Cheers,
Drew





Re: Windows Presentation Foundation (WPF) Binding vs Triggers

angelok

Makes sense, I think that I like the aspect of putting the brushes right in the style. Clearer separation of presentation. I guess as long as there's no perf penalty...