tags:

views:

78

answers:

3

How can i add different items with either background/foreground color different in WPF listbox?

A: 

After tearing my hair out with this one (and your particular usecase might differ from mine) I found the WPF Toolkit's DataGrid cured all my needs.

Graphain
A: 

You may use an AlternationCount property, more info provided by this link

Or you can add to your objs binded to a listbox Background and Foreground properties and bind them in a DataTemplate of ListBox.ItemTemplate and change them in code however you like, properties must update themselves on every changing.

Eugene Cheverda
A: 

You can can create a DataTemplete, set it to ListBox.ItemTemplate and use DataTrigger to change the display of the items.

ListBox has some very annoying behaviors that make styling it using data template difficult - in this blog post you will find the list of workarounds.

Nir