I have a project where I\'m trying to populate some data in a constructor:
public class ViewModel
{
public ObservableCollection Data { get;
In this particular case, a viewModel is required to launch the task and notify the view upon its completion. An "async property", not an "async constructor", is in order.
I just released AsyncMVVM, which solves exactly this problem (among others). Should you use it, your ViewModel would become:
public class ViewModel : AsyncBindableBase
{
public ObservableCollection Data
{
get { return Property.Get(GetDataAsync); }
}
private Task> GetDataAsync()
{
//Get the data asynchronously
}
}
Strangely enough, Silverlight is supported. :)