我怎么给交替行背景颜色和交替柱背景色在WPF列表视图? [英] How can i give alternating row background color and alternating column background color to the listview in WPF?
本文介绍了我怎么给交替行背景颜色和交替柱背景色在WPF列表视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
,也是我要的颜色头的背景。
请帮助。
And also i want to color the background of headers. Please help.
感谢
推荐答案
您需要设置一个风格与AlternationIndex集。 <一href=\"http://blogs.mscommunity.net/blogs/borissevo/archive/2008/10/21/wpf-trick-1-alternate-background-colors-for-listview-rows.aspx\">This 页面给出了一个例子
You need to set up a style with the AlternationIndex set. This page gives an example
(定义样式)
<Style x:Key="CustomListViewItemStyle" TargetType="{x:Type ListViewItem}">
<Style.Triggers>
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
<Setter Property="Background" Value="#2C2C2C"></Setter>
</Trigger>
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
<Setter Property="Background" Value="#262626"></Setter>
</Trigger>
</Style.Triggers>
</Style>
(使用定义的样式)
(using the defined style)
<ListView ItemContainerStyle="{DynamicResource CustomListViewItemStyle}"
AlternationCount="2">
...
</ListView>
这篇关于我怎么给交替行背景颜色和交替柱背景色在WPF列表视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文