我是 WP 新手。我尝试在ProgressIndicator
从服务器加载数据时显示并在加载完成时隐藏它。但是,我遇到了一个问题:“ProgressIndicator
我展示时唯一的展示MessageBox
。这是我的代码:
private void MainPageLoaded(object sender, RoutedEventArgs e)
{
// Create progress loading
SystemTray.ProgressIndicator = new ProgressIndicator();
SystemTray.ProgressIndicator.IsIndeterminate = true;
SystemTray.ProgressIndicator.IsIndeterminate = true;
SystemTray.ProgressIndicator.Text = "Loading...";
SyncDbIfNeed();
}
private void ShowHideProgressIndicator(Boolean isVisible)
{
SystemTray.ProgressIndicator.IsVisible = isVisible;
SystemTray.ProgressIndicator.IsIndeterminate = isVisible;
Debug.WriteLine("ShowHide: " + isVisible);
}
private async void SyncDbIfNeed()
{
if (!MySettings.IsCategorySynced())
{
ShowHideProgressIndicator(true);
try
{
HttpClient httpClient = new HttpClient();
String json = await httpClient.GetStringAsync(MyConstants.UrlGetAllCategory);
MessageBox.Show(json);
}
catch (Exception e)
{
MessageBox.Show("Unexpected error");
}
ShowHideProgressIndicator(false);
}
}
}
谁能解释一下,给我一个建议?谢谢。