23.01.2018 Views

MICROSOFT_PRESS_EBOOK_PROGRAMMING_WINDOWS_8_APPS_WITH_HTML_CSS_AND_JAVASCRIPT_PDF

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<br />

FIGURE 5-2 The <strong>HTML</strong> ListView essentials sample.<br />

The ListView’s constructor, WinJS.UI.ListView, is, of course, called by the ubiquitous WinJS.-<br />

UI.processAll when the page control is loaded. The data source for this list is set to myData.dataSource<br />

where myData is again a WinJS.Binding.List (defined at the top of js/data.js over a simple array) and its<br />

dataSource property provides the needed interface.<br />

The control’s item template is defined earlier in default.html with the id of smallListIconTextTemplate<br />

and is essentially the same sort of thing we saw with the FlipView (an img and some text elements), so I<br />

won’t list it here.<br />

In the control options we see three behavioral properties: selectionMode, tapBehavior, and<br />

swipeBehavior. These are all set to 'none' in this sample to disable selection and click behaviors entirely,<br />

making the ListView a passive display. It can still be panned, but the items don’t respond to input. (Also<br />

see the “Item Hover Styling” sidebar.)<br />

As for the layout property, this is an object of its own, whose type property indicates which layout to<br />

use. WinJS.UI.GridLayout, as we’re using here, is a two-dimensional top-to-bottom then left-to-right<br />

algorithm, suitable for horizontal panning. WinJS provides another layout type called WinJS.UI.-<br />

ListLayout, a one-dimensional top-to-bottom organization that’s suitable for vertical panning,<br />

especially in snapped view. (We’ll see this with the Grid App project template shortly; the ListView<br />

essentials sample lacks a good snapped view.)<br />

184

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!