In the spirit of separating out UI related logic from my ViewModels and keeping it restricted to the code actually driving the UI, I've come across a scenario that I don't quite know how to solve and would love some help with.
Background: I have a list of elements that will each have a different status (e.g., pending, complete, missed, etc.). I would like to apply a different background color to each item in the list based on that status. The ListView for this page is backed by a ViewModel that simply holds the data objects, and uses data binding in the XAML to surface the actual data.
Question: Being new to both XF and XAML, I can imagine how I'd like something like this to be executed, but don't know the proper way to do it. I would think I'd like something like this:
<Label Text="{Binding MyTextValue} BackgroundColor="{MethodThatReturnsAColor {Binding StatusOfObject}}" />
public Color MethodThatReturnsAColor(string status) {
if (status == "pending") {
return Color.Red;
}
// ... etc.
}
I've seen ObjectDataProviders used over in WPF land, but I don't think that's available in Forms, and I'm not even sure if that's the proper way to go about it. Any help and pointers would be great!