gpt4 book ai didi

.net - 如何在值不等于的情况下使用数据触发器

转载 作者:行者123 更新时间:2023-12-04 19:27:30 24 4
gpt4 key购买 nike

I have a Column 'Delivery Boy' in a data grid which is bind with a list in code behind. Values of DataGrid change dynamically.


<DataTrigger Binding="{Binding Path=delivery_boy}" Value="Not Assigned">
<Setter Property="Foreground" Value="DarkRed"/>
<Setter Property="Background" Value="Transparent"/>
</DataTrigger>

I can use 'Value' equals to in data trigger, how can I use data trigger for a case where I want the 'Value' property to be 'not equal to'


<DataTrigger Binding="{Binding Path=delivery_boy}" Value!="Not Assigned">
<Setter Property="Foreground" Value="White"/>
<Setter Property="Background" Value="Green"/>
</DataTrigger>

最佳答案

不知道为什么这会被否决,这是一个完全有效的问题。

通常,您通过在样式中分配默认 setter 然后仅使用 DataTriggers 来覆盖它们以响应特定值来实现此目的,即:

<Style>
<Setter Property="Foreground" Value="White"/> <!-- Default value -->
<Setter Property="Background" Value="Green"/> <!-- Default value -->

<Style.Triggers>
<DataTrigger Binding="{Binding Path=delivery_boy}" Value="Not Assigned">
<Setter Property="Foreground" Value="DarkRed"/>
<Setter Property="Background" Value="Transparent"/>
</DataTrigger>
</Style.Triggers>

</Style>

关于.net - 如何在值不等于的情况下使用数据触发器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51746840/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com