Note that there are some explanatory texts on larger screens.

plurals
  1. PORaise event only after dependent properties change value
    primarykey
    data
    text
    <p>I have this situation where I have several controls that are related to each other. I use two-way binding for the Current/SelectedValue of said controls, so that when a user changes the value, the change is reflected in the property of my viewmodel. The thing is, after the binding triggers the change at the setter of the changed property I need to change the other controls, based on the first, update the UI and then send only one event with the new values of all the affected properties. I was thinking of doing something in the lines of this (kind of something similar to IEditableObject):</p> <pre><code>public string PropA { get{(...)} set { BeginEdit("PropA"); PropA = value; PropB = SomeValueDependentOnA; PropC = SomeValueDependentOnA; OnPropertyChanged("PropA"); EndEdit("PropA"); //this is propA so send the event } public string PropB { get{(...)} set { BeginEdit("PropB"); PropB = value; PropA = SomeValueDependentOnB; PropC = SomeValueDependentOnB; OnPropertyChanged("PropB"); EndEdit("PropB"); } (...) </code></pre> <p>The begin/endedit methods would not do much, just check whether the prop that started the operation is the same that calls the endedit, so further beginedits would be ignored. The EndEdit we would make sure that only in the setter of PropA can we be certain that all the properties changed and we can send the event, kind of a transaction.</p> <p>Although I think this would work, I think this is kind of too much to be doing on the setter and the begin/endedit seems overkill for this simple thing.</p> <p>Maybe using 2-way binding is not the best option for this case and I should do the updates from methods in code behind instead of the property setters.</p> <p>Any sugestions on how to do this other way?</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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