There is a similar question(How to pass the UI Dispatcher to the ViewModel anyone provide me some example or full code.I am new to MVVM so I am not getting.
private async void BindMatchGridinAsync()
{
await BindMatchGridAsync();
}
async Task<ObservableCollection<EfesBet.DataContract.GetMatchDetailsDC>> BindMatchGridAsync()
{
await Task.Run(() =>
{
BindMatchGrid();
});
return null;
}
void BindMatchGrid()
{
BindMatchGridDel bindDel = new BindMatchGridDel(BindMatchGridData);
matchList = new List<GetMatchDetailsDC>();
matchList = proxy.GetMatch().ToList();
dataGridParent.Dispatcher.BeginInvoke(bindDel, null);
}
public delegate void BindMatchGridDel();
void BindMatchGridData()
{
dataGridParent.ItemsSource = matchList;
}
Now in this code BindMatchGridinAsync() I have put in my constructor of my code behind file(.cs file). It is giving a proper Asynchrous Operation. But I need to implement the same in ViewModel. Kindly suggest me how to implement it. Thanking you in advance.