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(); |
} |
} |
代码使用:<local:ListViewBackgroundConverter x:Key= "lvConverter" /> |
by: 发表于:2018-01-12 14:33:52 顶(0) | 踩(0) 回复
??
回复评论