Datagrid visual data refresh

1 Answer 113 Views
GridView
Sami
Top achievements
Rank 2
Iron
Iron
Iron
Sami asked on 01 Nov 2022, 08:09 PM

Hi:

I have a data grid connected to a collection view, when I update an object of entity framework the grid doesn't reflect the change Until I force reorder or something similar. The code that I'm using to edit is:

 Cliente cliente= db.Clientes.Find(1);
 cliente.Nombre = "SS";
 db.SaveChanges();  

 

I have the same problem if IConnect itemsource directly to a List or an observable collection:

  listaClientes = db.Clientes.ToList();

  dbGrid.ItemsSource = listaClientes;

 

Thanks in advance

 

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 02 Nov 2022, 07:42 AM

Hello Sami,

I already answered a very similar question in your other forum. In order for the UI to reflect the Nombre property change, the property setter should raise the PropertyChanged event. Can you check this on your side and see if it helps? 

As a side note, if you expect to add/remove items from the ItemsSource of any WPF control, I would recommend you to use a collection that implements INotifyCollectionChanged. Otherwise, the add/remove action won't update the UI. In other words, instead of List<Client>, you can use ObservableCollection<Client>. 

Regards,
Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Sami
Top achievements
Rank 2
Iron
Iron
Iron
commented on 02 Nov 2022, 10:31 PM

Thanks again for your help.
Tags
GridView
Asked by
Sami
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Martin Ivanov
Telerik team
Share this question
or