如何使用进度条在Windows Phone 7中下载大文件?
答案 0 :(得分:8)
虽然克劳斯的答案可行,但一个可能更容易的解决方案是使用网络客户端。它看起来像这样:
...
WebClient wb = new WebClient();
wb.DownloadProgressChanged += wbchange;
...
private void wbchange(object sender, DownloadProgressChangedEventArgs e)
{
progressBar2.Value = e.BytesReceived;
progressBar2.Maximum = e.TotalBytesToReceive;
int val = (int)(e.BytesReceived / 1048576);
int max = (int)(e.TotalBytesToReceive / 1048576);
textBlock4.Text = val + "MB out of " + max.ToString() + "MB";
}
此代码将显示带进度的进度条和带有MB进度的文本块。
答案 1 :(得分:2)