Reputation: 8324
I have a ListBox
that contains a StackPanel
with elements for binding. Based on a value, for instance 'Overdue' = true, the style of the StackPanel
and a few elements below should change. The only difference between each item is the background of the StackPanel
and the Foreground of two TextBlock
s would change. I thought about creating a separate template for each, but with 20 options, that seems like overkill. I have a SolidColorBrush
setup for each of the 20 items.
I thought I could use a DataTrigger, but I read somewhere that they are not supported in WP7 as WP7 supports Silverlight 3 and greater.
I'm looking for suggestions. I apologize that this may seem to be too subjective and hope someone has the best practice for this situation.
Upvotes: 0
Views: 332
Reputation: 46
You should consider using a ValueConverter that return SolidColorBrush based on the item's DataContext.
Take a look at Tim's blog, for code sample and detailed explanation.
Hope this helps.
Code From Home Dev
Upvotes: 1