You are correct in that you have to update the code to support asynchronous service calls. Nevertheless, you must take into account that in most general scenarios VM code is executed on the UI thread, but the service
call is executed on a different thread (not to block the UI).
That said, you can try removing the use of the Application.Current.Dispatcher.BeginInvoke() in the VM constructor. It is not necessary as you are probably already running on the UI thread, and as the Items property
is instantiated asynchronously on a later time bindings will probably fail.
public NetFlexResultsViewModel(INetFlexService netFlexService, IEventAggregator aggregator)
Items = new ObservableCollection<NetFlexResultItem>();
mNetFlexService = netFlexService;
In general callbacks from the service are executed on the calling thread (UIThread) in this case, so you won’t need to update the OnSearch method. If need to guarantee that the Items property is accessed
from the UI thread:
public void OnSearch(string title)
foreach (NetFlexResultItem item in res)
You can also take a look at the MVVM Quickstart (GetNewQuestionnaireInstance method of the QuestionnaireVM), that uses an asynchronous call with a call back that updates the UI.
On the other hand, I don’t see in your code where you are setting the VM as the datacontext for the V, but I assume that is correctly done somewhere else.