WPF Databinding and Styling based on Data in an item in an IList

Posted by Nate Bross on Stack Overflow See other posts from Stack Overflow or by Nate Bross
Published on 2009-06-19T21:52:09Z Indexed on 2010/04/18 17:23 UTC
Read the original article Hit count: 177

Filed under:
|
|
|

I have a ListBox bound to a list of Items (for arguement, lets say its got a string and two dates Entered and Done).

I would like to make the background color of items in the ListBox have a gray color if the Done DateTime is != DateTime.MinValue.

Edit:

Should I make a converter? and convert DateTime to a Brush based on the value of the DateTime?

Is something like this my best option? or is there a simple Xaml snippet I could use?

[ValueConversion(typeof(DateTime), typeof(Brush))]
class MyConverter : IValueConverter
{
    ...
}

© Stack Overflow or respective owner

Related posts about wpf

Related posts about databinding