I’m currently working on an app using MVVM that needs to have some data displayed in comboboxes. These are bound to ObservableCollections. The data is stored within a datatable.
I have a number of objects such as, for example, name and location. Each combobox contains either name or location. The list of names have a number next to them showing how many people are called that name. The location does similar. Now when the user clicks on a name, the numbers in the location box change to show how many people of that name live in the locations. The name and location objects are completely seperate and know nothing of each other. If the user then clicks on a location, then this would update the name combobox. The raw data is contained in a datatable with name and location column. (There will be approximately 7 comboboxes in the final project, and the dattable will increase accordingly). Is it a case of just querying the datatable again and clearing and replacing the objects in the combobox with the new data?
Sorry for the long winded message.
In case of complete changes of the lists, the
ObservableCollectiondoes little to help you. You might find it easier to have the combo boxes haveItemsSourceto properties on the ViewModel which return anIEnumerable<T>and callPropertyChangedwhen a particular item box is selected (SelectedItemis set).