windows系统的listview实现隔行变色的功能?怎么给偶数行增加一个浅色底纹,显得更加醒目?
参考这个例子:http://ask.csdn.net/questions/255140
http://blog.csdn.net/wesleyluo/article/details/8569341
using System;
using System.Collections.Generic;
using System.Linq;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Controls;
using System.Windows.Media;
public class ListViewBackgroundConverter :IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
ListViewItem item = (ListViewItem)value;
ListView listView =
ItemsControl.ItemsControlFromItemContainer(item) as ListView;
int index = listView.ItemContainerGenerator.IndexFromContainer(item);
if (index % 2 == 0)
{
return Brushes.White;
}
else
{
return Brushes.WhiteSmoke;
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}