Binding a collection to a grid view
Presenting items as rows using the list view is not the only way of showing a collection. You can also present items as tiles using the grid view, as shown in this recipe.
As an example, you will prepare a page with a grid view, where tiles will represent the categories of articles. Each tile will contain a name, a counter, and an icon. Of course, the example will use the data binding mechanism.
Getting ready
To step through this recipe, you need the automatically generated project configured according to the MVVM design pattern, as described in the Creating the view model for a page recipe.
How to do it...
To bind a collection to a grid view, in order to show a set of tiles on the page, perform the following steps:
Add the
Country.png
,World.png
,Local.png
,Culture.png
,Sport.png
, andGov.png
files (representing icons) to theAssets
directory. Example.png
files are available together with the code attached to this chapter.Add the
CategoryViewModel
class representing...