混淆类w/ databbinding中的数据

本文关键字:数据 databbinding | 更新日期: 2023-09-27 18:01:52

我试图在一个与数据绑定链接的类中编辑一些数据。这是我的类:

public class Line
{
    public string Equation { get; set; }
    public int PreviousLine { get; set; }
    public int LineNumber { get; private set; }
    public Line()
    {
        this.LineNumber = (this.PreviousLine + 5);
    }
}

但是行号总是返回5,即使前一行设置为6…

下面是我如何在我的视图模型中链接到它:

this.Lines.Add(new Line { Equation = "5*2", PreviousLine = 6 });

谢谢

混淆类w/ databbinding中的数据

 private int _previousLine;
    public int PreviousLine
    {
        get { return _previousLine; }
        set { _previousLine = value;
            Line = _previousLine + 5;
        }
    }
    public int Line { get; private set; }

尝试将其声明为静态

public static int PreviousLine { get; set; }