I have a ListBox bound to a list in ViewModel. I would like to "pin" certain ListBoxItems with different background color based on ViewModel. My view model looks like this, I want to highlight all the PinnedTasks in the ListBox. Seems like TypeConverter i开发者_StackOverflow社区s the best way to go, Are there any other approaches?
class ViewModel
{
public List<Task> Tasks { get; set; }// Bound to ListBox
public List<Task> PinnedTasks { get; set; } //These tasks are copy of Tasks,
//should be highlighted in ListBox
}
If you can somehow modify the Tasks class to add a Pinned property or, alternatively, create a ViewModel for the Task class that contains a Pinned property, then you should be able to accomplish this with a DataTrigger when Styling/Templating your tasks.
精彩评论