I have a viewmodel class that is assigned to my usercontrol
class UserControlViewModel
{
public bool A { get; set; }
public bool B { get; set; }
}
I'd like to bind some color to Background property that depends on A and B viewmodel properties. Something like:
A = true, B = true : Black
A = false, B = false: White
A = true, B = false: Green
A = false, B = true: Red
<UserControl Background="{Binding Path=???}" />
I guess it's possible to create converter for my case that should accept UserControlViewModel instance and convert A and B properties into Brush instance and vise versa.
Or may be I shall create another property that implements conversion logic:
class UserControlViewModel
{
public bool A { get; set; }
public bool B { get; set; }
public Brush MyBrush {
get {
if (A && B) return Brushes.Black;
...
}
}
}
What is the best way to solve my problem?