public abstract class BaseViewModel : INotifyPropertyChanged
{
#region INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChanged(
[CallerMemberName] string propertyName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
}
Now you can extend the BaseViewModel and use it this way:
public class UserViewModel : BaseViewModel
{
{
private string login;
public string Login
{
get
{
return login;
}
set
{
if (login == value)
return;
login = value;
RaisePropertyChanged();
}
}
private string password;
public string Password
{
get
{
return password;
}
set
{
if (password == value)
return;
password = value;
RaisePropertyChanged();
}
}
}
[ImplementPropertyChanged]
public abstract class BaseViewModel {}
public class UserViewModel : BaseViewModel
{
public string Login { get; set; }
public string Password { get; set; }
}
No comments:
Post a Comment