[英]wpf vb.net Datagrid image in row depending on value in cell
This is the code i use but it is notworking 这是我使用的代码,但没有用
<Window.Resources>
<Style x:Key="PinkRow" TargetType="{x:Type DataGridRow}">
<Style.Triggers>
<DataTrigger Binding="{Binding Rank}" Value="Master">
<Setter Property="Source" Value="A_Cancel.png"/>
</DataTrigger>
<DataTrigger Binding="{Binding RANK}" Value="Bosun">
<Setter Property="Background" Value="Green" />
</DataTrigger>
<DataTrigger Binding="{Binding RANK}" Value="">
<Setter Property="Background" Value="yellow" />
</DataTrigger>
</Style.Triggers>
</Style>
</Window.Resources>
If field rank has the value "Master" i want the image A_cancel.png 如果字段等级的值为“ Master”,则我需要图像A_cancel.png
The C# is case sensitive, so the Rank
and RANK
are different properties. C#区分大小写,因此
Rank
和RANK
是不同的属性。 Use proper property name in your bindings. 在绑定中使用正确的属性名称。 Also you must mention in your Setter the
TargetName
for Image
element. 您还必须在Setter中提及
Image
的TargetName
元素。
<DataTrigger Binding="{Binding Rank}" Value="Master">
<Setter TargetName="ImageElementName" Property="Source" Value="A_Cancel.png"/>
</DataTrigger>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.