wpf datagrid备用行着色 [英] wpf datagrid alternate row coloring
本文介绍了wpf datagrid备用行着色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试过这种方法..没有运气。
I have tried this method.. without luck..
<Style TargetType="{x:Type DataGridRow}">
<Style.Triggers>
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
<Setter Property="Foreground" Value="Red" />
</Trigger>
</Style.Triggers>
</Style>
是否可以获取行索引?
我什至尝试过
Is there a way to get the row Index? I have even tried
<DataTrigger Binding="{Binding AlternationIndex}" Value="0">
<Setter Property="Foreground" Value="Green"></Setter>
</DataTrigger>
推荐答案
除非已完成,否则必须设置AlternateCount属性的DataGrid:
Unless already done, you have to set the AlternationCount property of DataGrid:
<DataGrid AlternationCount="2"
... />
您还应该检查Foreground属性是否用于DataGridRow中的任何控件。尝试设置Background属性来测试交替的东西。
You should additionally check whether the Foreground property is used for any Control in the DataGridRow. Try setting the Background property to test the alternation stuff.
这篇关于wpf datagrid备用行着色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文