这是一堆触发器。问题是,如果我将最后一个触发器放在<DataTrigger Value="True">
之前,那么如果其他匹配则甚至不会进入转换器。为什么会这样? WPF不遵循声明的顺序但尝试优化吗?因为如果我留下空的setter,那么它永远不会进入转换器。
<DataTemplate.Triggers>
<DataTrigger Value="0">
<DataTrigger.Binding>
<MultiBinding Converter="{StaticResource tableOrderConvertor}">
<Binding Path="."></Binding>
<Binding ElementName="control" Path="DataContext.ActiveOrders"></Binding>
</MultiBinding>
</DataTrigger.Binding>
<Setter Property="Background" Value="{StaticResource TableFullBrush}" TargetName="table"/>
<Setter Property="Foreground" Value="#2DFF5A" TargetName="tableName"/>
<Setter Property="BorderBrush" Value="#346902" TargetName="table"/>
</DataTrigger>
<DataTrigger Value="1">
<DataTrigger.Binding>
<MultiBinding Converter="{StaticResource tableOrderConvertor}">
<Binding Path="."></Binding>
<Binding ElementName="control" Path="DataContext.ActiveOrders"></Binding>
</MultiBinding>
</DataTrigger.Binding>
<Setter Property="Background" Value="{StaticResource TableFullBrush}" TargetName="table"/>
<Setter Property="Foreground" Value="#F79644" TargetName="tableName"/>
<Setter Property="BorderBrush" Value="#346902" TargetName="table"/>
</DataTrigger>
<DataTrigger Value="2">
<DataTrigger.Binding>
<MultiBinding Converter="{StaticResource tableOrderConvertor}">
<Binding Path="."></Binding>
<Binding ElementName="control" Path="DataContext.ActiveOrders"></Binding>
</MultiBinding>
</DataTrigger.Binding>
<Setter Property="Background" Value="{StaticResource TableFullBrush}" TargetName="table"/>
<Setter Property="Foreground" Value="#16D4FF" TargetName="tableName"/>
<Setter Property="BorderBrush" Value="#346902" TargetName="table"/>
</DataTrigger>
<DataTrigger Value="True">
<DataTrigger.Binding>
<MultiBinding Converter="{StaticResource tableOwnerConvertor}">
<Binding Path="."></Binding>
<Binding ElementName="control" Path="DataContext.ActiveOrders"></Binding>
<Binding ElementName="control" Path="DataContext.SelectedShift"></Binding>
</MultiBinding>
</DataTrigger.Binding>
<Setter Property="Background" Value="Red" TargetName="table"/>
</DataTrigger>
<!-- trigga gia my table -->
</DataTemplate.Triggers>