GridView- binding to groups of different ViewModel

2019-03-03 20:05发布

问题:

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