简体   繁体   English

WPF Multitrigger不能为空

[英]WPF Multitrigger Can't be null

This is my Multitrigger: 这是我的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. 如果我将此触发器用作DataTrigger ,则绑定有效。

But I need the AlternationIndex . 但我需要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. 我以为是因为我是通过SQL加载数据,但是当我在SQL之后加载样式时,我仍然遇到绑定具有NULL值的问题。

From documentation I can read that you should refer to your AlterationIndex like so: 从文档中我可以读到你应该像你这样引用你的AlterationIndex
{Binding RelativeSource={RelativeSource Self}, Path=(ItemsControl.AlternationIndex)}
MSDN Doc MSDN Doc
HTH HTH

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM