0

所以我一直在这个问题上摸不着头脑,但我无法弄清楚。我经历了一些调试步骤来查看它挂在哪里,而 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 
        }
    }
    //...
}
4

1 回答 1

2

根据您在评论中的回答,我们看到您在 setter 中没有任何断点,而是尝试使用 F11(进入)到达那里。除非您禁用相应的调试器设置,否则它将无法工作。打开工具->选项->调试。找到选项“跳过属性和运算符”(默认情况下应启用)并将其禁用。或者在设置器中设置断点,如果更方便的话。

于 2013-10-25T22:17:33.400 回答