C # UWP Windows 10 project

There are two ComboBox data sources of which are two ObservableCollection .

Both ComboBox bound to two variables in ViewModel in Mode=TwoWay . Klas ViewModel implements INotifyPropertyChanged .

The Dilem is that the set of values ​​of these ComboBox 's should be mutually exclusive, that is, when choosing a value in the first one - the set of values ​​in the second should change (a certain filter will overlap) and vice versa.

When you call ObservableCollection.Clear() and fill it with new data, respectively, INotifyPropertyChanged and INotifyCollectionChanged are repeatedly called, INotifyPropertyChanged stack to overflow (infinite loop).

Actually the question is - how to solve such a problem?

  • Do only remove element. - Monk
  • one
    Well, there should be no problems. At the time of applying filtering, coerce a boolean flag that says that it is temporarily not necessary to pay attention to changes coming from the filtered combo box. At the end of the ObservableCollection, clear the flag. - VladD

0