I'm using MVVM
pattern with WPF
application.
Data I'm getting from device which is communicating with my application (Desktop) via USB communication.
Here is my MVVM structure:
In Model: I'm getting data from device (which run on WinCE plateform)
Here I have created an event public event EventHandler<PropertyEventArgs> propertyChanged;
protected void RaisepropertyChangedEvent(PropertyEventArgs e)
{
if (this.propertyChanged != null)
{
this.propertyChanged(this, e);
}
}
public class PropertyEventArgs : EventArgs
{
public int lf { get; set; }
public int dateformat { get; set; }
public string pid { get; set; }
public int language { get; set; }
public int Line { get; set; }
public string Label { get; set;}
public int uValue { get; set; }
public int lvalue { get; set; }
public int lMethod { get; set; }
}
In View Model I'm raising this event:
When some data is coming, then I'm raising this event:
this.RaisepropertyChangedEvent(this.pargs);
In UI: I have subscribed this event to Update UI
this.eObj.propertyChanged += new EventHandler<PropertyEventArgs>(this.EpropertyChanged);
private void EpropertyChanged(object sender, PropertyEventArgs e)
{
this.OnPropertyChanged(new PropertyChangedEventArgs("linePercentage"));
this.OnPropertyChanged(new PropertyChangedEventArgs("Label"));
this.OnPropertyChanged(new PropertyChangedEventArgs("UL"));
this.OnPropertyChanged(new PropertyChangedEventArgs("LMethod"));
}
eobj
is place where Eventargs
I have declared.
Problem which I'm facing is that when value of property change, all the property is getting called.
Because of that sometime wrong value is getting set for some parameter.
Please help me to solve this problem.