I am using Xamarin forms.
I have a simple View that contains a couple of list views. The whole view has a BindingContext with a viewmodel. The view model class contains a BackgroundColor. Question: How can I access the BackgroundColor property from within the listview's dataTemplate.
ViewModel.cs
public class TestViewModel {
public System.Drawing.Color BackgroundColor { get; set; }
public List<Employee> Employees { get; set; }
}
An instance of the above class is set a BindingContext to the view View.xaml
<ContextPage.... >
....
<listview ItemsSource="{Binding Employees}"...
<DataTemplate>
<Grid BackgroundColor="{Binding BackgroundColor}">
</ContentPage>
The above grid's background does not work as the current context is now on the Employee collection. So how can I access the "BackgroundColor" within the view model when in the list view.