I have been trying to get a Listbox to store objects which contains the elements of a SfDataGrid and then, let the user fill the SfDataGrid with the data stored in the object by clicking the Listbox item. The problem I am facing is that once I assign new values to the SfDataGrid elements to create a new object, the values of the already created object (which is already in the Listbox) have their values changed too. How can I avoid that?
What I am doing: I am getting the SfDataGrid's elements through the ItemsSource property and adding them to a new List, which is what my object stores. To get the elements back to he SfDataGrid, I am adding the elements back from this list to a new instance of my view model's ObservableCollection and reassigning the DataContext to this view model. The ItemsSource is also reassigned, but to the ObservableCollection.
Can you please confirm whether you are reporting the issue that we are have replicated in the above video? If yes, this is because, you are creating new instance for viewmodel each time, due to this, the reported issue occurs. Instead, you can directly access existing datacontext of datagrid and add selected item from listbox. If the reported issue is different from the one we replicated, please revert us with the modified sample/Video illustrating the replication procedure, in order to investigate further and provide appropriate solution at earlier.