使用 LongListSelector 根据用户输入对 WP7 中的数据进行排序/分组

发布于 2024-10-09 21:09:57 字数 1019 浏览 0 评论 0原文

我正在为 Windows Phone 7 开发一个库存显示应用程序(主/详细信息),用户可以更改排序。数据源是来自网络的 XML,根据所选的排序,结果要么是平面列表(按名称、型号等排序),要么是按所选属性(颜色、尺寸等)分组。 。我将预先确定排序是否返回平坦与分组,并且用户无法选择它。

我正在 WP7 数据透视控件中显示结果,并且希望/需要不同的排序出现在同一个 PivotItem 中(将排序放在不同的 PivotItems 中并不是真正的选择)。列表的源是一个 Observable Collection(实际上此时它是一个 CollectionViewSource,但我并不热衷于其中任何一个)。我正在使用 MVVM Light 框架。

我使用过 Silverlight Toolkit 中的 LongListSelector,看起来它可以满足我的需求。我读过很多帖子(从 WP7 ListBox Grouping 开始),并且实际上让它适用于平面列表(不应用排序,只是默认值,因为它来自源)。现在我正在尝试找出正确的使用方法。

我的问题:

  • 是否可以重新构造数据的显示方式(平面/排序与分组),而无需构建/维护相同信息的多个可观察集合(每个排序变体一个)? ?
  • 如果没有,最好的方法是将数据本地副本保存在手机上并从那里开始工作吗?我预计我会降低复杂性,但会节省性能/响应能力。

  • 要在同一 PivotItem 中显示各种结果,我应该创建具有适当格式的用户控件并根据所选排序将它们交换到数据透视表中,还是可以通过动态 ItemSource & 来完成此操作? ItemTemplate 更改?

  • Observable Collection/CollectionViewSource 是去这里的方法吗?

答案完全有可能(甚至很可能)就在我眼前,但我对这些东西还很陌生,而且我已经遇到了数据过载。我确实需要一些指导。

谢谢, 富有的

I’m working on an inventory display app (master/details) for Windows Phone 7 where the user has the ability to change the sorting. The source of the data is XML from the web, and depending on the sort chosen, the results are either a flat list (sorted by name, model number, etc.) or grouped by the selected attributes (color, size, etc.). I'll pre-determine whether the sort returns flat vs. group and it won't be user selectable.

I’m displaying the results in a WP7 pivot control and want/need the different sorts to appear in the same PivotItem (putting the sorts in different PivotItems isn’t really an option). The source for the list is an Observable Collection (actually at this point it’s a CollectionViewSource, but I’m not wedded to either). I’m using the MVVM Light framework.

I’ve played with LongListSelector from the Silverlight Toolkit and it looks like it does what I want. I've read a number of posts (starting with WP7 ListBox Grouping) and actually have it working for the flat list (no sort applied, just default as it is from the source). Now I’m trying to figure out the right way to use it.

My questions:

  • Is it possible to re-structure the way the data is displayed (flat/sorted vs. grouped) without having to build/maintain multiple observable collections of the same info (one for each sort variant)?

  • If not, is the best method to save a local copy of the data locally on the phone and work from there? I expect I'd take a hit on complexity but pick up savings on perf/responsiveness.

  • To display the various results in the same PivotItem, should I create user controls with the appropriate formatting and swap them in to the pivot based on the chosen sort, or can I do it via dynamic ItemSource & ItemTemplate changes?

  • Is Observable Collection/CollectionViewSource the way to go here?

It’s entirely possible (even likely) the answers are staring me in the face, but I’m new to this stuff and I’ve hit data overload. I could really use some guidance.

Thanks,
Rich

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

睫毛上残留的泪 2024-10-16 21:09:57

是否可以重新构建数据的显示方式(平面/排序与分组),而无需构建/维护相同信息的多个可观察集合(每个排序变体一个)?

我认为您可以尝试使用 LINQ 查询给定的集合,并使用该查询作为 LLS 的源。我不确定性能如何,但你可以尝试一下。或者,IIRC 的各种 *ViewSource 集合都有更改数据视图的方法,因此您可以检查一下。

Is it possible to re-structure the way the data is displayed (flat/sorted vs. grouped) without having to build/maintain multiple observable collections of the same info (one for each sort variant)?

I think what you could try is using LINQ to query your given collection, and use that query as the source for your LLS. I'm not sure on how the performance would be, but you can give it a try. Alternatively, IIRC the various *ViewSource collections have ways of changing the view of your data, so you can check those out.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文