Reputation: 5133
In a ListView I have a GridView where the row background is colored depending on a property of the item in the data context of the row.
Currently I set the color using a trigger in the ItemContainerStyle of the ListView:
<DataTrigger Binding="{Binding Path=State}" Value="Active">
<Setter Property="Background" Value="Red"/>
</DataTrigger>
<DataTrigger Binding="{Binding Path=State}" Value="Confirmed">
<Setter Property="Background" Value="Green"/>
</DataTrigger>
This works fine, but instead of the fixed colors in the data trigger I would like to bind to a color setting instead. I could add a binding in the Value property of the setter, but I would like the existing row colors in the GridView to update if the color setting changes. Binding in the setter will only update the color of rows added after the setting is changed.
I could code my way out of this, by subscribing to property change events for my settings or something similar, but I am hoping for an elegant binding trick.
Requirements:
Upvotes: 0
Views: 337
Reputation: 9255
What is a GridView in WPF ? DataGrid ?
Maybe you can bind the Background
property of the row with a multibinding on State
and a color palette objet.
Upvotes: 0