代码:
<Grid>
<s:SmartGridView ItemsSource="{Binding MasterView}" SelectedItem="{Binding CurrentItem}">
<s:SmartGridView.RowStyle>
<Style TargetType="telerik:GridViewRow">
<Style.Triggers>
<!-- 天藍色 -->
<DataTrigger Binding="{Binding PortNo}" Value="2">
<Setter Property="Foreground" Value="SkyBlue" />
</DataTrigger>
<!-- 紫色 -->
<DataTrigger Binding="{Binding PortNo}" Value="4">
<Setter Property="Foreground" Value="Purple" />
</DataTrigger>
</Style.Triggers>
</Style>
</s:SmartGridView.RowStyle>
<s:SmartGridView.Columns>
<s:SmartDataColumn Header="口岸代碼" DataMemberBinding="{Binding PortNo}" />
<s:SmartDataColumn Header="口岸名稱" DataMemberBinding="{Binding PortName}" />
</s:SmartGridView.Columns>
</s:SmartGridView>
</Grid>
效果:
口岸代码为 2 的变成了天蓝色,4的变成了紫色。