c# - WPF - setting properties to themselves fails to fire changed event -


Here is a unique piece of behavior. We recently created some code in a WPF MVVM application that looked a bit like this:

  foreach (var mA in preferences. Where (itm => itm.Preference == "Y")) {Member M = _members.FirstOrDefault (itm = & gt; itm.MemberID == mA.MemberAvertedID); If (m = = null) {m.Selected = true; }} Subscribers = _members;  

Therefore, the first default receives a reference for a member, which is updated. The members and members are effectively the same - the former is a property, wrapping it later as a private variable, with an event fire:

  public supervision qualification & lt; Members & gt; Members {meet {return _members;} set {_members = value; OnPropertyChanged ("member"); }}  

The purpose of the members to set up members was to bring the incident to the fire only - but this does not work. As you stepped through, OnPropertyChanged fired the event, but the application did not respond. This, however, works:

  foreach (var mA in preferences. Where (itm = & gt; itm.Preference == "Y")) {member M = _members.FirstOrDefault ( Itm = & gt; itm.MemberID == mA.MemberAvertedID); If (m = = null) {mtc.selected = true; }} Var mem = new Observation Collection & Lt; Members & gt; (_ Member); Member = mem;  

I am assuming what is happening here is that setting members as members is effectively the property's setting, code has been "estimated" that something Has not changed, and leaves the incident. But I am not really satisfied with this explanation. Can anyone tell me what's going on here?

The binding list will not change the list until the archive reference is different, so the last of the code The piece is working. He said, unless you are actually adding or removing items from the underlying _members list, you should not redeem the entire list.

If your goal is to refresh the status of the selected member, probably you have been selected from selected from the property OnPropertyChanged (" Selected ") is decreasing.

In summary: The property that is changing should be named in the event converted into property. In this case, the WPF need to raise the notification on the member example to change the property in the selected property, and the incident should come from the object that is the owner of the property. / P>


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -