tags:

views:

32

answers:

1

Hi,

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 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

A: 

Yes, in either case you'd need a DataTemplate. In fact, the only time you can get away with not using a DataTemplate is if you're happy with the default format of the text in each ListBoxItem.

BTW, you missed another option:

  • Use a converter to determine whether the value falls in the appropriate range.

That said, if you're doing MVVM, I'd generally recommend your second option.

HTH, Kent

Kent Boogaart