-1

I have a login page in my application and on the page i have a textbox that shows the error in case of wrong username/password, etc. I am updating the error from view model, but the view is not changing automatically.

The viewmodel implements INotifyPropertyChanged interface.

Error definition.

string _error;

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

INotify Event Handlers

public event PropertyChangedEventHandler PropertyChanged;

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

update

_error = "Wrong username/password!";

xaml

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

What else am i missing?

Manoj
  • 314
  • 1
  • 2
  • 12

1 Answers1

2

set your error like this, you're just changing the private member that isn't being binded to:

Error="Wrong username/password!";

not _error

devuxer
  • 41,681
  • 47
  • 180
  • 292