I have object with 3 property:
CouldBeWhite bool
CouldBeGreen bool
CouldBeRed bool
If CouldBeWhite is true, then foreground of row should be white, if
CouldBeGreen is true, and CouldBeWhite is false, then row should be
Green If CouldBeRed is true, and and CouldBeWhite is false and
CouldBeGreen is false then row should be Red In other case row
should be blue.
My idea now is to have some new property at viewmodel Color, when I would count color of row.
Or maybe there is some nicer way to implement this?
Add this enum to your project:-
Then add this property to your ViewModel:-
Call UpdateRowState when every the
CouldBeXXXproperties change.Consider that you are probably not making the foreground white or red or green just as a whim. There will be be some reason why its white, red or green. So in your code think of a simple short name to represent those reasons and replace the color names with those more meaningful names.
Now go fetch the code for
StringToValueConverterin this blog. Add an instance of this to your Xaml in theUserControl.Resources:You can bind on a
TextBlock: