RowIndexConverter.cs 803 B

12345678910111213141516171819202122232425262728293031
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. namespace FWindSoft.Wpf
  10. {
  11. public class RowIndexConverter : IValueConverter
  12. {
  13. /*必须开启虚拟化才能使用Index
  14. */
  15. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  16. {
  17. DataGridRow row = value as DataGridRow;
  18. if (row!=null)
  19. {
  20. return row.GetIndex() + 1;
  21. }
  22. return 0;
  23. }
  24. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  25. {
  26. return value;
  27. }
  28. }
  29. }