Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to reflect propertychange for an entity to ViewModal in WPF
    primarykey
    data
    text
    <p>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.</p> <hr> <p><strong>Entity</strong></p> <pre><code>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 </code></pre> <p><strong>VIEWMODAL</strong></p> <pre><code>public class DIPREDIPViewModel : BaseViewModel { public DIPREDIPForView Configuration { get { return configuration; } set { configuration = value; } } } </code></pre> <p><strong>BaseViewModal</strong></p> <pre><code>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 } </code></pre> <p>What i want is whenever "Configuration" changes,ViewModal should be notified as i have to call someother logic based on this.</p> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload