Note that there are some explanatory texts on larger screens.

plurals
  1. POOnPropertyChanged reaction different the first time and the second time
    primarykey
    data
    text
    <p>I have got a collection of viewModels(InputViewModel) in an other viewModel(ScenarioManager). each InputviewModel has an instance of a Class(RestOfInput) which contains properties able to raise the OnPropertyChanged. when one of these properties changes the event is handled by this method (in InputViewModel) :</p> <pre><code> public void TestAfterChanges(object sender, PropertyChangedEventArgs e) { MessageBox.Show("not ref"); bool isInTheList = false; RestOfInput roi = sender as RestOfInput; string prop = e.PropertyName; if (prop!="NameFile") { Difference d = new Difference(); d.Length = prop; d.Value1 = reference.RoI.getValueByPropertyName(prop); d.Value2 = roi.getValueByPropertyName(prop); foreach (Difference diff in _ListOfDifferences) { if (diff.Length==prop) { if ( (Math.Abs(d.Value2-d.Value1)&gt;0.001*d.Value1)) { //replace by le new one _ListOfDifferences.Insert(_ListOfDifferences.IndexOf(diff), d); _ListOfDifferences.Remove(diff); } else { //if change make the field value equal to the ref then remove from difference list _ListOfDifferences.Remove(diff); } isInTheList = true; } } if ((Math.Abs(d.Value2 - d.Value1) &gt; 0.001 * d.Value1) &amp;&amp; isInTheList==false) { _ListOfDifferences.Add(d); } } } </code></pre> <p>this method gives just a summary of the differences between this particular case and the reference case.</p> <p>Now if the reference case changes I have to update all the cases and the event is handled in ScenarioManager :</p> <pre><code> public void refCaseChanging(object sender, PropertyChangedEventArgs e) { MessageBox.Show("ref"); string propname = e.PropertyName; foreach (InputViewModel item in _casesList) { if (item!=inpVM) { item.RoI.OnPropertyChanged(propname); } } } </code></pre> <p>inpVM is the reference case. </p> <p>Then I have this behavior : -if I change a field in a case which is not the reference case : everything is ok. -if I change a particular field in the reference case : the first time, everything is ok. But the second time, only the reference case and the first case (in the collection) which is not the reference case are updated> It is like the foreach loop is broken..</p> <p>Any explications.</p> <p>If the message is not clear please tell me ( not easy to explain ;) )</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