[英]WP7 Toolkit PerformanceProgresBar and UI thread (losing dots effect)
我很难管理WP Toolkit中的ProgressBar。 在我的项目中,我有一个列表框,其中填充了数据绑定项。 填充过程如下:
我现在的问题是:Indeterminate标志似乎改变得太快(我认为不同的线程?)。 这导致进度条有时只显示一个矩形。 如何确保仅在数据绑定和列表框刷新完成后进度条才会消失?
这是我的响应回调:
private void DataLoaded(object o, RestResponseEventArgs e)
{
int i = 0;
List<Entry> entries = new List<Entry>();
foreach (JObject current in e.JsonObject["entries"].Children())
{
Entry e = Entry.Parse(current);
entries.Add(e);
}
this.MyListBox.ItemsSource = entries;
this.ProgressBar.Visibility = Visibility.Collapsed;
this.ProgressBar.IsIndeterminate = false;
}
使用Dispatcher.BeginInvoke()方法:
private void DataLoaded(object o, RestResponseEventArgs e)
{
Dispatcher.BeginInvoke(() =>
{
int i = 0;
List<Entry> entries = new List<Entry>();
foreach (JObject current in e.JsonObject["entries"].Children())
{
Entry e = Entry.Parse(current);
entries.Add(e);
}
this.MyListBox.ItemsSource = entries;
this.ProgressBar.Visibility = Visibility.Collapsed;
this.ProgressBar.IsIndeterminate = false;
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.