23.01.2018 Views

MICROSOFT_PRESS_EBOOK_PROGRAMMING_WINDOWS_8_APPS_WITH_HTML_CSS_AND_JAVASCRIPT_PDF

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

• Though win-item is listed as a style, it’s deprecated and may be removed in the future: just style<br />

the item template directly.<br />

• The documentation points out that styles like win-container and win-surface are used by<br />

multiple WinJS controls. (FlipView uses a few of them.) If you want to override styles for a<br />

ListView, be sure to scope your selectors them with other classes like .win-listview or a<br />

particular control’s id or class.<br />

• The default ListView height is 400px, and the control does not automatically adjust itself to its<br />

content. You’ll almost always want to override that style in <strong>CSS</strong> or set it from JavaScript when<br />

you know the space that the ListView should occupy, as we’ll cover in Chapter 6, “Layout.”<br />

• Styles not shown in the figure but described on Styling the ListView and its items include<br />

win-focusedoutline, win-selection, win-selected, win-selectionborder,<br />

win-selectionbackground, and win-selectionhint. There is also the win-selectionstylefilled<br />

class that you add to an item to use a filled selection style rather than the default bordered style,<br />

as shown here:<br />

Backdrops<br />

There is another ListView visual that is a bit like styling but not affected by styling. This is called the<br />

backdrop, an effect that’s turned on by default when you use the GridLayout. On low-end hardware,<br />

especially low-power mobile devices, panning around quickly in a ListView can very easily outpace<br />

the control’s ability to load and render items. To give the user a visual indication of what they’re<br />

doing, the GridLayout displays a simple backdrop of item outlines based on the default item size and<br />

pans that backdrop until such time as real items are rendered. As we’ll see in the next section, you<br />

can disable this feature with the GridLayout’s disableBackdrop property and override its default gray<br />

color with the backdropColor property.<br />

Layouts and Cell Spanning<br />

The ListView’s layout property, which you can set at any time, contains an object that’s used to organize<br />

the list’s items. WinJS provides two prebuilt layouts: WinJS.UI.GridLayout and WinJS.UI.ListLayout.<br />

The first, already described earlier in this chapter, provides a horizontally panning two-dimensional<br />

layout that places items in columns (top to bottom) and then rows (left to right). The second is a<br />

one-dimensional top-to-bottom layout, suitable for vertical lists (as in snapped view). These both follow<br />

the recommended design guidelines for presenting collections.<br />

216

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

Saved successfully!

Ooh no, something went wrong!