Items Collection
Display a highly performant list of views powered by JSON data and an item template.
Inherits from Sharpnado.CollectionView
About
At some point in your mobile development career... there will come a point in which you need to display a list of items, either horizontally or vertically. These items will all look the same and be powered from a singular data source (likely a Lava entity command).
Like most, your first attempt will likely look something like this:
And who knows, maybe that is enough to get the job done and call it a day... Or maybe it isn't.
You may realize pretty quickly that with a lot of items, the performance starts to deteriorate. Most layouts simply aren't built to handle that many items generated in the form of raw XAML. If you've been in the game a while, you may have experimented with CollectionView or CarouselView, which are performant alternatives. The ItemsCollection (this) control is a friendlier, viable and stable alternative to both of those controls.
This control requires an item height (or width). This plays a big factor with performance. If you need a list with differently sized items, take a look at one of the alternatives listed above.
Properties
Collection View Layout
Usage
Let's get into the business... how can we display long lists (horizontally OR vertically) without killing performance and maintaining a smooth scroll experience? The answer can be achieved with four simple steps.
Define your data source as JSON
Bring your JSON into memory
Create a single item template
Set up your Items Collection container
Examples
Make sure to use Rock:ViewCell
as the base of your template. This control has some special logic to make sure the views are properly dark mode responsive.
Last updated