I have a ListBox whose ItemsSource is databound to a list of ints.
I’d like to bold bold a few of the items, on the basis of their value.
There are two options that come to (my) mind:
1) Use a DataTrigger that bolds the value if it’s a match.
2) Use a class to wrap the ints and pair each int with a boolean that denotes if the value should be bolded or not.
In any case I’d need a DataTemplate/ItemTemplate, right?
I’ve played around with this but haven’t got it working yet.
Cheers,
Pom
Yes, in either case you’d need a
DataTemplate. In fact, the only time you can get away with not using aDataTemplateis if you’re happy with the default format of the text in eachListBoxItem.BTW, you missed another option:
That said, if you’re doing MVVM, I’d generally recommend your second option.