C# 如何在windows phone上发出json请求时显示正在加载的消息?

C# 如何在windows phone上发出json请求时显示正在加载的消息?,c#,asynchronous,windows-phone,loading,C#,Asynchronous,Windows Phone,Loading,在windows phone上发出json请求时,我需要显示一条加载消息,就像Android上带有ProgressDialog的异步任务一样,在onPreExecute()上放置dialog.show(),在onPostExecute()上放置dialog.disease()。如何在windows phone上执行此操作 以下是我的json请求: WebClient webClient = new WebClient(); webClient.DownloadStringComplete

在windows phone上发出json请求时,我需要显示一条加载消息,就像Android上带有ProgressDialog的异步任务一样,在onPreExecute()上放置dialog.show(),在onPostExecute()上放置dialog.disease()。如何在windows phone上执行此操作

以下是我的json请求:

WebClient webClient = new WebClient();
    webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);
    webClient.DownloadStringAsync(new Uri("https://maps.googleapis.com/maps/api/place/textsearch/json?&query=taxi&location=-19.94549444,-43.92314218&&radius=5000&sensor=true&key=AIzaSyDucC8QBV5wu4V-dQXFfABXGaaUzdmT5xw"));

下载此请求时,我需要显示加载消息,并在请求完成时将其输入。

您可以显示进度条以指示正在进行的进程。
只需将代码如下所示:

WebClient webClient = new WebClient();
webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);

ProgressIndicator progressIndicator = new ProgressIndicator() {
    IsVisible = true,
    IsIndeterminate = false,
    Text = "Loading..." 
};

SystemTray.SetProgressIndicator(this, progressIndicator);
webClient.DownloadStringAsync(new Uri("https://maps.googleapis.com/maps/api/place/textsearch/json?&query=taxi&location=-19.94549444,-43.92314218&&radius=5000&sensor=true&key=AIzaSyDucC8QBV5wu4V-dQXFfABXGaaUzdmT5xw"));
这将在您的请求开始执行时显示一个进度条。
要在加载后停止此操作,请向事件处理程序添加以下代码:

void webClient_DownloadStringCompleted(s, e)
{
    Dispatcher.BeginInvoke( () =>
    {
        progressIndicator.IsVisible = false;
        // Your code
    });
}

删除帖子中的解决方案不起作用?对我来说也不起作用。@DanielNazareth:很高兴:)如何将此加载放在屏幕中央?