LISTBOX数据为什么不更新

gzdemon 2014-03-25 05:06:01
下载http://192.168.0.1/a.txt,写入本地储存a.txt.
然后,更新http://192.168.0.1/a.txt的内容,再次下载写入本地存储a.txt
listbox显示还是前一次a.txt内容(有6个TXT文件)
程序有删除和下载功能,可实时删除本地文件,LISTBOX这里为空,但点下载后,内容还是旧数据
怀疑是不是WINDOWS PHONE有系统缓存有问题?

本程序只有从手机卸载后,重新布署,才更新LISTBOX的数据。不知是什么问题,请大师们指教

程序片断如下:
private void readerPivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Pivot ItemsSelsectGet = sender as Pivot;
List<RssVar> tempList = new List<RssVar>();
if (ItemsSelsectGet != null)
{
if (ItemsSelsectGet.SelectedIndex == 0) titleList0.ItemsSource = null;
if (ItemsSelsectGet.SelectedIndex == 1) titleList1.ItemsSource = null;
if (ItemsSelsectGet.SelectedIndex == 2) titleList2.ItemsSource = null;
if (ItemsSelsectGet.SelectedIndex == 3) titleList3.ItemsSource = null;
if (ItemsSelsectGet.SelectedIndex == 4) titleList4.ItemsSource = null;
if (ItemsSelsectGet.SelectedIndex == 5) titleList5.ItemsSource = null;
if (ItemsSelsectGet.SelectedIndex != 6)
{
// Get the local folder.
//显示加载进度条
TxtMessageTip.Text = "正在加载";
TxtMessageTip.Visibility = Visibility.Visible;
Pbr.Visibility = Visibility.Visible;
Pbr.IsIndeterminate = true;

// Get the DataFolder folder.
IsolatedStorageFile userStore = IsolatedStorageFile.GetUserStoreForApplication();

if (!userStore.DirectoryExists("DataFolder"))
{
userStore.CreateDirectory("DataFolder");
}
string filePath = Path.Combine("DataFolder", rssFileNameArr[ItemsSelsectGet.SelectedIndex]);
if (userStore.FileExists(filePath))
{
StreamReader reader = new StreamReader(userStore.OpenFile(filePath,
FileMode.Open, FileAccess.Read));
string contents = reader.ReadToEnd();
reader.Close();
try
{
tempList = JSONConvert.FromJson<List<RssVar>>(contents);
}
catch
{
TxtMessageTip.Text = "Json格式错误!";
}
}
//LISTBOX显示
if (ItemsSelsectGet.SelectedIndex == 0) titleList0.ItemsSource = tempList;
if (ItemsSelsectGet.SelectedIndex == 1) titleList1.ItemsSource = tempList;
if (ItemsSelsectGet.SelectedIndex == 2) titleList2.ItemsSource = tempList;
if (ItemsSelsectGet.SelectedIndex == 3) titleList3.ItemsSource = tempList;
if (ItemsSelsectGet.SelectedIndex == 4) titleList4.ItemsSource = tempList;
if (ItemsSelsectGet.SelectedIndex == 5) titleList5.ItemsSource = tempList;




//隐藏提示
TxtMessageTip.Visibility = Visibility.Collapsed;
Pbr.Visibility = Visibility.Collapsed;
Pbr.IsIndeterminate = false;

}

}
}
...全文
279 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
vbfool 2014-03-26
  • 打赏
  • 举报
回复
引用 4 楼 gzdemon 的回复:
[quote=引用 3 楼 vbfool 的回复:] 个人意见,你这代码写这样,不会卡么?
刚开始学,所以先只考虑实现功能,再想办法优化。 由于是读取本地文件,数据量不大的话还没感觉有卡顿。[/quote] 做WP其实对这方面还是挺敏感的,能异步的就异步,能放到别的线程去的就放,UI线程事越少越好。
gzdemon 2014-03-26
  • 打赏
  • 举报
回复
引用 3 楼 vbfool 的回复:
个人意见,你这代码写这样,不会卡么?
刚开始学,所以先只考虑实现功能,再想办法优化。 由于是读取本地文件,数据量不大的话还没感觉有卡顿。
vbfool 2014-03-26
  • 打赏
  • 举报
回复
个人意见,你这代码写这样,不会卡么?
gzdemon 2014-03-26
  • 打赏
  • 举报
回复
引用 5 楼 vbfool 的回复:
[quote=引用 4 楼 gzdemon 的回复:] [quote=引用 3 楼 vbfool 的回复:] 个人意见,你这代码写这样,不会卡么?
刚开始学,所以先只考虑实现功能,再想办法优化。 由于是读取本地文件,数据量不大的话还没感觉有卡顿。[/quote] 做WP其实对这方面还是挺敏感的,能异步的就异步,能放到别的线程去的就放,UI线程事越少越好。[/quote] 嗯,谢谢提醒,以后的开发多注意这方面的效率。以后还要多多请教了。。
gzdemon 2014-03-25
  • 打赏
  • 举报
回复
不好意思,找到问题来源了,是webClient的缓存问题,现在想怎么解决下载单个TXT文件强制刷新,就可以了。
Nick_Ngai 2014-03-25
  • 打赏
  • 举报
回复
顶一下,我之前也有个类似问题,我在其他页面获取另一个页面ListBox,重新绑定数据,但是没有刷新新数据。 后来干脆直接new XXXPage(); 然后再绑定重新绑定数据。

7,657

社区成员

发帖
与我相关
我的任务
社区描述
Windows Phone是微软发布的一款手机操作系统,它将微软旗下的Xbox LIVE游戏、Zune音乐与独特的视频体验整合至手机中。
社区管理员
  • Windows客户端开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧