Binding data in LongListSelector

无人久伴 提交于 2019-11-29 13:01:36

I believe you should set your items source to an observablecollection

I didn't do it exactly like you, but here is my xaml and here is a viewmodel for an app I build for the windows phone store.

I also believe it is key to clear and then set your items source on update. When I was building a WPF app, I seem to remember spending a lot of time trouble shooting the observablecollection not updating.

When you do this

var selected = (from c in myList group c by c.MainTitle into n select new GroupingLayer<string, MyObject>(n)).ToList();

you get a list where every item has:

  • a Key property (in your case containing MainTitle value) because you group by MainTitle!
  • a list of "child" items

When you define your DataTemplate, you can bind the property "Key" because exists in this new list, but SubTitle does not exists, so you can't show it!

You can take a look at this sample:

http://code.msdn.microsoft.com/wpapps/PhotoHub-Windows-Phone-8-fd7a1093

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!