GridView- binding to groups of different ViewModels? (Combining Images and Text articles)

杀马特。学长 韩版系。学妹 提交于 2019-12-02 18:50:00

问题


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.

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


回答1:


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



来源:https://stackoverflow.com/questions/12152406/gridview-binding-to-groups-of-different-viewmodels-combining-images-and-text

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