GridView- 绑定到不同 ViewModel 的组?(图文结合文章) [英] GridView- binding to groups of different ViewModels? (Combining Images and Text articles)

查看:26
本文介绍了GridView- 绑定到不同 ViewModel 的组?(图文结合文章)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想弄清楚如何将 GridView 与组的不同类一起使用.在 GridApp 模板中,所有内容都继承自 SampleDataCommon,您是否总是必须从 GridView 中的一个公共类继承?文档似乎……缺乏这方面的内容.

I'm tying to figure out how to use the GridView with different classes for groups. In the GridApp template everything inherits from SampleDataCommon, do you always have to inherit from a common class in the GridView? The documentation seems.. lacking on this mater.

更新:具体来说,我要解决的问题是拥有一个包含图像图块和文本新闻文章的 GridView.

UPDATE: Specifically the problem I'm trying to solve is to have a GridView with both image tiles and text news articles.

推荐答案

您可以绑定到任何类类型.我会建议他们实现一个通用的接口或类.如果他们不能,那么将它们分组是没有意义的.您可以使用 DataTemplateSelector 显示组内的项目.这是一个非常简单的例子和一个更复杂的示例

You can bind to any class type. I would suggest that they implement a common interface or class. If they cannot, then grouping them just does not make sense. You can display the items within the group by using a DataTemplateSelector. Here is a very simple example and a more complex sample

这篇关于GridView- 绑定到不同 ViewModel 的组?(图文结合文章)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆