-
Notifications
You must be signed in to change notification settings - Fork 0
Data Binding
Cy Scott edited this page Aug 22, 2021
·
2 revisions
Interfaces that inherit from INotifyPropertyChanged or INotifyPropertyChanging will invoke the PropertyChangedEventHandler and PropertyChangingEventHandler events respectively when property values are changing / changed. Here is a simple example of how it works:
[Generate]
public interface IHaveAnId : INotifyPropertyChanged, INotifyPropertyChanging
{
Guid Id { get; set; }
}
The generated code will look like:
public class HaveAnIdModel : IHaveAnId
{
public System.Guid Id
{
get
{
return _Id;
}
set
{
PropertyChanging?.Invoke(this, new System.ComponentModel.PropertyChangingEventArgs("Id"));
_Id = value;
PropertyChanged?.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs("Id"));
}
}
private System.Guid _Id;
public event System.ComponentModel.PropertyChangedEventHandler? PropertyChanged;
public event System.ComponentModel.PropertyChangingEventHandler? PropertyChanging;
public SupportNotifyPropertyChangingModel()
{
}
}