One of the areas that has seen the most change between Windows 8 and Windows 8.1 is the WinJS ListView control. The whole control was basically overhauled from its WinJS 1.0 incarnation. It's WinJS 2.0 version is much more performant, supports drag and drop, used CSS grid/flexbox for layout rather than absolute positioning, supports more built-in layouts, makes it easy to write custom layouts, and improves keyboard support.
Toward that end, this post is summarizes all the changes that are documented or that I've encountered in writing the book chapter.
First of all, here's the list of ListView 1.0 features that are deprecated in ListView 2.0, and what replaces them:
Incremental loading properties. Incremental loading is handled either through the data source or the item rendering function. The new HTML ListView incremental loading behavior sample (http://code.msdn.microsoft.com/windowsapps/ListView-loading-behaviors-718a4673) shows how, by adding more items to the Binding.List in the item renderer.
Backdrops were a feature added late for ListView 1.0 as a band-aid for its performance on ARM devices. Given that ListView 2.0 performs so much better, this feature is often no longer needed, but even so, it's handled through CSS now. So the following properties are obsolete in favor of the win-backdrop CSS selector in WinJS 2.0:
- ListLayout: backdropColor, disableBackdrop
GridLayout: backdropColor, disableBackdrop
The GridLayout's new orientation property obsoletes its earlier horizontal property. A GridLayout supports both vertical and horizontal orientations.
The ListLayout's vertical property is obsolete in favor of the orientation property, which supports both vertical and horizontal.
Cell spanning happens how through the CellSpanningLayout class, obsoleting the GridLayout's earlier cell-spanning features:
itemInfo, groupInfo, and maxRows. In the CellSpanningLayout you'll find itemInfo, groupInfo, and maximumRowsOrColumns.
- itemInfo, groupInfo, and maxRows. In the CellSpanningLayout you'll find itemInfo, groupInfo, and maximumRowsOrColumns.
The ListView's resetItem and resetGroupHeader methods are deprecated because the control no longer recycles items. In WinJS 1.0, as a performance optimization, a rendering function could receive a second parameter that was an already-created item element tree, in which you'd replace the data. These properties let you centralize the cleanout process, but as recycling is no longer used, these methods do nothing.
- The earlier IListLayout and related interfaces for custom layouts, which were really never documents, are obsolete. Layout has been overhauled from an absolute positioning model (which introduced many performance issues) to one based on pure CSS. As a result, the custom layout model for WinJS 2.0 is much simpler, using the IListLayout2 and related interface. The HTML ListView custom layout sample shows this (http://code.msdn.microsoft.com/windowsapps/HTML-ListView-custom-9676a187).
It's good to note that WinJS.Binding.Template controls are compiled by default in WinJS 2.0. If you find a problem with that, the Template object has an option called disableOptimizedProcessing that, when set to true, will impose the WinJS 1.0 interpreted template model.
Other changes to the ListView for WinJS 2.0 introduce new features and capabilities:
- Invocable headers: groupHeaderTapBehavior and headerInvoked properties.
- Drag and drop: itemDrag* events, itemsDraggable, itemsReorderable properties.
- ListView uses maxDeferredItemCleanup property instead of 1000 as the default.
- ListView implements the WinJS standard dispose pattern and triggerDispose
- CSS-based layout, which enables easier custom layouts, improves performance quite a bit.