所以我一直在这个问题上摸不着头脑,但我无法弄清楚。我经历了一些调试步骤来查看它挂在哪里,而 Visual Studio 不会给我任何东西。基本上,我有一个带有数组的类,它跟踪数组的当前索引和当前图像。
但是,当我在调试(或不调试)时,无论“index”的值是多少,“currentLocation”都不会更新。我似乎无法弄清楚问题可能是什么。有什么建议么?
public class TestClass : INotifyPropertyChanged
{
//...
public void GoTo(int index)
{
if (index == currentLocation)
return;
else if (index >= data.Length)
this.currentLocation = data.Length - 1;
else if (index <= 0)
this.currentLocation = 0;
else
this.currentLocation = index;
//this is where the debugging drops off
}
//doesn't matter if I initialize the value or not
//private int _currentLocation = 0;
private int _currentLocation;
public int currentLocation
{
get { return _currentLocation; }
set
{
//never hits this line
this.SetProperty(ref this._currentLocation, value);
//more work
}
}
//...
}