为什么视图不更新?

Why isn't the view updating?

我的应用程序中有一个登录页面,在该页面上我有一个文本框,在错误的情况下显示错误 username/password,等等。我正在从视图模型更新错误,但视图是不会自动更改。

视图模型实现了 INotifyPropertyChanged 接口。

错误定义。

string _error;

    public string Error
    {
        get { return _error; }
        set 
        {
            _error = value;
            NotifyPropertyChanged("Error");
        }
    }

INotify 事件处理程序

public event PropertyChangedEventHandler PropertyChanged;

    protected void NotifyPropertyChanged(String info)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(info));
        }
    }

更新

_error = "Wrong username/password!";

xaml

<TextBlock Text="{Binding Error, UpdateSourceTrigger=PropertyChanged}"/>

我还缺少什么?

像这样设置错误,您只是在更改未绑定到的私有成员:

Error="Wrong username/password!";

不是_error