2 namedajipai namedajipai 于 2016.05.09 23:10 提问

windows系统的listview实现隔行变色的功能?

windows系统的listview实现隔行变色的功能?怎么给偶数行增加一个浅色底纹,显得更加醒目?

4个回答

caozhy
caozhy   Ds   Rxr 2016.05.15 07:17
已采纳
CSDNXIAON
CSDNXIAON   2016.05.09 23:22

Android:横行滚动且隔行变色的ListView控件
----------------------同志你好,我是CSDN问答机器人小N,奉组织之命为你提供参考答案,编程尚未成功,同志仍需努力!

u014339882
u014339882   2016.05.11 19:54

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();
    }
}

oyljerry
oyljerry   Ds   Rxr 2016.05.10 09:32
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!