i have created a user control with three dependency properties selected value selected item selected index when one of them changes in the call back i am setting the other two e.g if selected value changed i am setting Selected index and selected item which in result triggering the callback of each of other properties where it sets the other two properties and keeps on in loop .how to avoid this situation
Asked
Active
Viewed 79 times
1 Answers
0
That's easy,
in each Property Setter only set the other two when the value you're setting is different from the the existing value (through the call of GetValue()). Add a If statement to check this in each of the Property setters.
You should be more careful with these type of situations, either check if you really need those 3 properties as Dependency Properties or change some of them to normal properties in the ViewModel if you're using an MVVM framework.
If you're using MVVM, many frameworks provide a method to suppress notifications like ReactiveUI (ReactiveObject.SuppressChangeNotifications()) or MVVM Light Tookit.

tmoreira
- 124
- 3