| 123456789101112131415161718192021222324252627282930313233 | using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Media;namespace FurnaceUI.Converter{    /// <summary>    /// ListView 控件 自增行序号    /// </summary>    public class ListViewIndexConverter : IValueConverter    {        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)        {            ListViewItem item = (ListViewItem)value;            ListView listView = ItemsControl.ItemsControlFromItemContainer(item) as ListView;            int index = listView.ItemContainerGenerator.IndexFromContainer(item) + 1;            return index.ToString();        }        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)        {            throw new NotImplementedException();        }    }}
 |