The problems are simple: when updating ItemsSource Combobox is not updated, for example. new items do not appear in the list of items in the list.
I tried the solution from an aseptic answer to this question: WPF - update combobox contents to update with no luck.
here is my xaml code:
<ComboBox Name="LeadTypeComboBox" ItemsSource="{Binding LeadTypeCollection}" />
ViewModel:
public ObservableCollection<XmlNode> LeadTypeCollection { get; set; }
the way I update this collection is in a separate method that loads data from the updated XML file: this.LeadTypeCollection = GetLeadTypesDataSource();
I also tried using Add for testing:
this.LeadTypeCollection = GetLeadTypesDataSource(); ItemToAdd = LeadTypeCollection[LeadTypeCollection.Count - 1]; this.LeadTypeCollection.Add(ItemToAdd);
The code update build is definitely starting, I see new items in this collection when debugging, but I donβt see them in the drop-down list.
Doing this in the work of LeadTypeComboBox.ItemsSource = MyViewModel.GetLeadTypesDataSource(); code works: LeadTypeComboBox.ItemsSource = MyViewModel.GetLeadTypesDataSource(); , but I would like to achieve this using MVVM, that is, the code should be in the ViewModel, which does not know about managing the LeadTypeComboBox.
source share