I did not find any similar question, except for those where changes do not occur when adding an element. And my problem is that there is
public ObservableCollection<Note> Notes {get; set;} In the constructor of this class, I initialize this list.
Notes = new ObservableCollection<Note>(helper.GetChildNodes()); And everything is fine. But during the execution of the program, it is necessary to repeat a piece of code that is written above, but at the same time helper.GetChildNodes() already returns other values.
But the list for some reason does not update the binding with ListBox
<ListBox Grid.Row="1" ItemsSource="{Binding Notes}" DataContext="{Binding}" SelectedItem="{Binding SelectedNote}"> What to do? Tell me please!
необходимо повторить кусок кода- the entire stringNotes = new ObservableCollection<Note>(helper.GetChildNodes());? If yes, then this is a mistake, because the binding happens to the object that was created earlier, and you reinitialize it withnew. - EvgeniyZ 7:26 pmNotesshould only be initialized once, that's all. Further you do not touch its initialization. Add through.Add()and similar methods. That is, the best option is to go through thehelper.GetChildNodes()loop and add each element toNotes. Or make an event through which you will add new objects (again through.Add(). - EvgeniyZ