using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Controls; using System.Windows.Data; namespace FWindSoft.Wpf { public class RowIndexConverter : IValueConverter { /*必须开启虚拟化才能使用Index */ public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { DataGridRow row = value as DataGridRow; if (row!=null) { return row.GetIndex() + 1; } return 0; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { return value; } } }