public class LDLTrackViewModel : RailwayViewModel { private LDLTrack _ldlTrack; public LDLTrack LDLTrack { get => _ldlTrack; set { _ldlTrack = value; OnPropertyChanged("LDLTrack"); } } public LDLTrackViewModel(LDLTrack ldlTrack) { LDLTrack = ldlTrack; LineCoords = new ObservableCollection<LineCoordinates>(ldlTrack.LineCoordList); ZIndex = -50; } }
My system is set up that I've filled my models with data through reading a big file. I then pass these models to various view models via their constructor (I have the same amount of view models as I do models):
LDLTracks = new ObservableCollection<LDLTrackViewModel>(TrainSimAllData.AllLDLTracks.Select(ldl => new LDLTrackViewModel(ldl))); Where LDLTracks is a collection of LDLTrackViewModels. I then bind to this list of view models in my view. I'm wondering if this is the normal way to go about things or whether there's a better approach?