I have an entity which inherits from INOTIFYPROPERTYCHANGED, this entity is bound to my UI elements like TextBOX. Now when any property is changed, my bindings are updated and everything works fine. What I want is to trap this propertychanged event in my viewmodal. my viewmodal also inherits from INOTIFYPROPERTYCHANGED.
Entity
public class DIPREDIPForView:INotifyPropertyChanged
{
#region PrivateFields
private string fieldDelimiter, textQualifier;
#endregion
public DIPREDIPForView()
{
}
public string FieldDelimiter
{
get
{
return fieldDelimiter;
}
set
{
fieldDelimiter = value;
OnPropertyChanged("FieldDelimiter");
//NotifyViewModalEvent();
}
}
public string TextQualifier {
get
{
return textQualifier;
}
set
{
textQualifier = value;
OnPropertyChanged("TextQualifier");
//NotifyViewModalEvent();
}
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
public virtual void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = this.PropertyChanged;
if (handler != null)
{
var e = new PropertyChangedEventArgs(propertyName);
handler(this, e);
}
}
#endregion
VIEWMODAL
public class DIPREDIPViewModel : BaseViewModel
{
public DIPREDIPForView Configuration
{
get
{
return configuration;
}
set
{
configuration = value;
}
}
}
BaseViewModal
public class BaseViewModel : INotifyPropertyChanged, IDisposable
{
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
public virtual void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = this.PropertyChanged;
if (handler != null)
{
var e = new PropertyChangedEventArgs(propertyName);
handler(this, e);
}
}
#endregion
}
What i want is whenever "Configuration" changes,ViewModal should be notified as i have to call someother logic based on this.
I have tried calling OnPropertyChanged() in the setter of Configuration,but it doesnot fire. whenever i update a value on UI,This configuration is updated but breakpoint in the setter is not hit. How should i achieve this.