I’m rather a newbie with WPF and still playing with bindings and such, so this probably a basic question.
Consider the following class:
class DataHolder
{
public List<int> Data;
// Points to one of the items in Data. Thus can be between 0 and Data.Count
public int Pointer;
}
I’ve set a ListBox’s DataContext to be an instance of the class above and its ItemSource is the ‘Data’ of the instance.
Now I’d like to mark in the ListBox the color of the list item that holds Data[Pointer] to be gray color.
What should I use? I’ve tried doing it with DataTriggers but I am not sure how to compare two different values using them. I’d rather not use IValueConverter at this point, unless it is impossible to do otherwise.
EDIT: Feel free to convert the public data to properties in the mentioned class
Thanks!
I’ve done things like this before by creating what I call a DataViewModel. This is basically a ViewModel for each item in the collection. I tried it quick with your example and it worked. I’ll paste all my code below, should be able to pull it in and execute it if you wish.
MainWindow.xaml
MainWindow_ViewModel.cs
DataHolder.cs
Data_DataViewModel.cs