Reputation: 1254
I got a WPF client application that connected to a wcf service reference.
My models are from the service reference only.
I want to create a viewmodel for each model, how can i add NotifyPropertyChangedEvent without adding each property manually from the model to the viewmodel
I saw in mvvm light , that the model can ineherit from ObservebleObject, only problem is that the model is created else where and i'm just getting the reference.
Any ideas ?
Thanks
Upvotes: 0
Views: 268
Reputation: 21713
Everytime you call a method on your service, it's going to return a new DTO. It will never give you the same instance back, and you can't use a service to manipulate one object instance - all data used in communication is transient.
So those instances can never be updated (they're not models) so implementing INotifyPropertyChanged
would be pointless. Instead you need to write a view model and copy your DTOs into that. The view model is where you would implement INotifyPropertyChanged
.
Upvotes: 1
Reputation: 30097
I don't think it is must to put the implementation of INotifyPropertyChanged
in Model
. You can simply implement it in ViewModel
.
Why your View
needs to tell the Model
(via ViewModel
) that something has been changed ? I think it should only tell ViewModel
that there has been a change. Then let View Model
play with Model
.
Upvotes: 0