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.

You can use this method within a binding initializer, as demonstrated in Scenario 1 of the aforementioned<br />

StorageDataSource and GetVirtualizedFilesVector sample, or within a rendering function<br />

that takes the place of the declarative template. We’ll do this for our FlipView sample later on, in “How<br />

Templates Really Work,” which also lets us avoid the one-time binding tricks.<br />

As a final note, Scenario 6 of the FlipView sample contains another example of a different data<br />

source, specifically one working with Bing Search. For that, let’s look at custom data sources.<br />

Custom Data Sources<br />

Now that we’ve seen a collection control like FlipView working against two different data sources, you’re<br />

probably starting to correctly guess that all data sources share some common characteristics and a<br />

common programmatic interface. This is demonstrated again in Scenario 6 of the FlipView sample as<br />

well as in the <strong>HTML</strong> ListView working with data sources sample shown in Figure 5-6, as we’ll see in this<br />

section.<br />

FIGURE 5-6 The <strong>HTML</strong> ListView working with data sources sample.<br />

Scenarios 2 and 3 of this sample both work against a WinJS.Binding.List data source, as we’ve<br />

already seen, and provide buttons to manipulate that data source. Those changes are reflected in the<br />

output. The difference between the two scenarios is that Scenario 2 manipulates the data through<br />

WinJS.Binding.List methods like move, whereas Scenario 3 manipulates the underlying data source<br />

directly through a more generic ListDataSource. API.<br />

204

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

Saved successfully!

Ooh no, something went wrong!