alielie
2025-03-13 a3ba25607612818c28d421bfa8eb2f92339d71ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Globalization;
using System.Windows.Controls;
using System.Windows.Data;
 
namespace HMI.UI.Converter
{
    public class DataGridRowNumberConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is DataGridRow row)
            {
                return row.GetIndex() + 1;
            }
            return -1;
        }
 
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value;
        }
    }
 
    //public class ListBoxItemIndexConverter : IValueConverter
    //{
    //    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    //    {
    //        if (value is ListBoxItem row)
    //        {
    //            return row.GetIndex() + 1;
    //        }
    //        return -1;
    //    }
 
    //    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    //    {
    //        return value;
    //    }
    //}
}