gpt4 book ai didi

WPF数据网格交替行着色

转载 作者:行者123 更新时间:2023-12-03 07:07:15 24 4
gpt4 key购买 nike

我尝试过这个方法..没有运气..

 <Style TargetType="{x:Type DataGridRow}">
<Style.Triggers>
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
<Setter Property="Foreground" Value="Red" />
</Trigger>
</Style.Triggers>
</Style>

有没有办法获取行索引?我什至尝试过

<DataTrigger Binding="{Binding AlternationIndex}" Value="0">
<Setter Property="Foreground" Value="Green"></Setter>
</DataTrigger>

最佳答案

最后,这就是我最终设置备用行颜色的结果。

<Style TargetType="{x:Type DataGrid}">
<Setter Property="Background" Value="#FFF" />
<Setter Property="AlternationCount" Value="2" />
</Style>

<Style TargetType="{x:Type DataGridRow}">
<Style.Triggers>
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
<Setter Property="Background" Value="#CCC"></Setter>
</Trigger>
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
<Setter Property="Background" Value="#EEE"></Setter>
</Trigger>
</Style.Triggers>
</Style>

关于WPF数据网格交替行着色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4792628/

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