views:

81

answers:

2

Why this doesn't work?

 <Style x:Key="ItemContStyle" TargetType="{x:Type ListViewItem}">
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=Asset}" 
          Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}},
                       Path=CurrentAsset}">
                <Setter Property="Background" Value="Red" />
            </DataTrigger>
  </Style.Triggers>

+1  A: 

Because DataTrigger.Value is not a dependency property.

Thomas Levesque
So... how can I set background of ListView items according to some criteria?
Ike
I thought about Style, Setter, Converter and ConverterParameter but it doesn't work... ConverterParameter also can't get the binding - it's also not a dependency property...
Ike
I'm not sure you can, at least not easily... unless you create your trigger dynamically in code. Or perhaps you could inherit Setter and add a ValueBinding property... probably not so easy
Thomas Levesque
I will try StyleSelector
Ike
yes, good idea... I forgot about that
Thomas Levesque
A: 

Used StyleSelector instead...

Ike