Reputation: 835
I would like to take advice from your side. As you know mostly in xamarin formsenter code here
using mvvm
pattern in the view models
, people used to use most of the time ObservableCollection
to hold items. I have old windows forms application
and some class libraries
when i have methods which get data as DataTable
. I already migrated all class libraries from .NET framework
to .Net Standard
to be able to share logic also in Xamarin
, nevertheless i wonder how i can deal when getting data for instance DataTable GetAllPeple()
. Should i just somehow convert DataTable
placed in my repository class
data to ObseravbleCollection
placed in ViewModel? Can anyone give me a hint how this could be done. Also vice versa when want to update some records.
Hope you got my point. Thanks to all of you.
Upvotes: 0
Views: 253
Reputation: 1405
If you follow the MVVM or similar pattern, you should handle the GetAllPeople data in the ViewModel only, and put it into the Model (to the ObservableCollection) along with other model data the View needs. If you can access the DataTable as a collection and get rows and columns, create a class with needed properties (and INotifyPropertyChanged) turn the rows and columns into properties in the class and add to the ObservableCollection.
Upvotes: 1