DataForm visual refresh problem

1 Answer 59 Views
DataForm GridView
Sami
Top achievements
Rank 2
Iron
Iron
Iron
Sami asked on 01 Nov 2022, 07:31 PM

HI I have a DataForm where itemSource is a CollectionView source created with this 3 alternatives:

  c = CollectionViewSource.GetDefaultView(db.Clientes.Local.ToObservableCollection());
  c = CollectionViewSource.GetDefaultView(db.Clientes.ToList<Cliente>());
 c = CollectionViewSource.GetDefaultView(db.Clientes.Local.ToList<Cliente>());

 

db is a Context with entityFramework 6. When I edit dataForm the changes the poco doenst appear in the dataform but they are saved in to database.

  dataForm.BeginEdit();

   Cliente cliente =(Cliente) dataForm.CurrentItem ;
   cliente.Nombre = cliente.Nombre+"-";

 

 

Could you give me an advise to solve it?

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

Thanks for your help. It's working now. It is a good practice to use INotifyPropertyChanged with EtityFrame work?

1 Answer, 1 is accepted

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

Hi Sami,

In order for the UI to reflect the updates of the data model (Client in your case), the updated property should raise the PropertyChanged event. In other words, the underlying object should implement the INotifyPropertyChanged interface.

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:30 PM

 

Thanks for your help. It's working now. It is a good practice to use INotifyPropertyChanged with EtityFrame work?
Martin Ivanov
Telerik team
commented on 03 Nov 2022, 09:54 AM

The recommended approach is to use MVVM wrappers classes over the EntityFramework entity models. For example, if you have an EF class named Person, you can create a (lets call name it) PersonWrapper class that can copy the information from Person and can be used in the WPF's UI. This requires some additional code to sync the EF models with the view model, but this approach is more reliable because you will avoid modifying the EF models with information that is not needed by EF. Also, you will have more freedom when it comes to application-based modifications in the models. 

You can check the following discussions on the topic:

* https://stackoverflow.com/questions/14132349/implement-inotifypropertychanged-on-generated-entity-framework-classes

https://stackoverflow.com/questions/1261371/reducing-boilerplate-code-in-mvvm-wpf-app-for-attached-properties-commands-etc

 
Tags
DataForm GridView
Asked by
Sami
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Martin Ivanov
Telerik team
Share this question
or