i have a List that i would like to pass to the ViewModel.Intuitively i thought it would be straightforward by passing it is a parameter to the ViewModel's constructor but on doing that i get the error that a ViewModel's constructor should be parameterless...This being the case:
public SomeMethod(){
List<T> list = new List<T>();
ViewModel vm = new ViewModel(list);
}
the viewmodel:
public class ViewModel
{
public ObservableCollection<T> Collection { get; set; }
public ViewModel(List<T> t)
{
Collection = new ObservableCollection<T>();
foreach (T item in t)
{
this.Collection.Add(new T (item.value));
}
}
what other ways can i pass the list to the ViewModel..for one i thought of creating another method in the ViewModel that accepts the list as a parameter,but how would i be able to call it from the constructor since the constructor has to pass the parameter to it too.