I have a project where I\'m trying to populate some data in a constructor:
public class ViewModel
{
public ObservableCollection Data { get;
you can use Action inside Constructor
public class ViewModel
{
public ObservableCollection Data { get; set; }
public ViewModel()
{
new Action(async () =>
{
Data = await GetDataTask();
}).Invoke();
}
public Task> GetDataTask()
{
Task> task;
//Create a task which represents getting the data
return task;
}
}