wpfxamlbindingdatagridmultitrigger

WPF Multitrigger Can't be null


This is my Multitrigger:

<MultiDataTrigger>
    <MultiDataTrigger.Conditions>
        <Condition Binding="{Binding Path=Dringlichkeit, RelativeSource={RelativeSource Self}}" Value="Normal"/>
        <Condition Property="ItemsControl.AlternationIndex" Value="0"/>
    </MultiDataTrigger.Conditions>
    <Setter Property="Background" Value="LightPink"/>
</MultiDataTrigger>
<MultiDataTrigger>
    <MultiDataTrigger.Conditions>
        <Condition Binding="{Binding Path=Dringlichkeit, RelativeSource={RelativeSource Self}}" Value="Normal"/>
        <Condition Property="ItemsControl.AlternationIndex" Value="1"/>
    </MultiDataTrigger.Conditions>
    <Setter Property="Background" Value="Pink"/>
</MultiDataTrigger>

If I use this trigger as a DataTrigger, the binding works.

But I need the AlternationIndex. I thought it was because I was loading the data via SQL, but when I load the style after SQL, I still have the problem that the binding has a NULL value.


Solution

  • From documentation I can read that you should refer to your AlterationIndex like so:
    {Binding RelativeSource={RelativeSource Self}, Path=(ItemsControl.AlternationIndex)}
    MSDN Doc
    HTH