HTML ListView item templates sample

This sample demonstrates how to use WinJS.Binding.Template objects and rendering functions to display items for a ListView. It also shows how to enable cell-spanning templates for variably sized items.

4.8 Star
7,366 times
Add to favorites
E-mail Twitter Digg Facebook
<!DOCTYPE html>
<html xmlns="">
    <link rel="stylesheet" href="/css/scenario1.css" />
    <script src="/js/data.js"></script>
    <script src="/js/scenario1.js"></script>
    <div data-win-control="SdkSample.ScenarioInput">
        <!-- This sample shows simple scenarios for using the ListView control with in-memory data and
         declarative templates. These may not scale for larger sets of data or complex UI. See the
         HTML ListView Optimizing Performance and
         HTML ListView Working with DataSources samples
         for examples of custom datasources and render functions. -->
            The Windows Library for JavaScript has a built-in templating engine that enables
            developers to easily create item templates, such as the one used in the ListView
            in this example. Many of the templates that Windows uses are provided on the Windows
            developer center so that you can copy and paste them into your own apps.
        <br />
        <br />
    <div data-win-control="SdkSample.ScenarioOutput">
        <div id="regularListIconTextTemplate" data-win-control="WinJS.Binding.Template" style="display: none">
            <div class="regularListIconTextItem">
                <img src="#" class="regularListIconTextItem-Image" data-win-bind="src: picture" />
                <div class="regularListIconTextItem-Detail">
                    <h4 data-win-bind="innerText: title"></h4>
                    <h6 data-win-bind="innerText: text"></h6>

        <div id="listView" 
                itemDataSource: myData.dataSource, 
                itemTemplate: regularListIconTextTemplate, 
                selectionMode: 'none', 
                tapBehavior: 'none', 
                swipeBehavior: 'none', 
                layout: { type: WinJS.UI.GridLayout }