A simple way to use the ListView in the Win8 app

Source: Internet
Author: User

This is the Win8 app's sacred and inviolable header file:

>    <meta CharSet="Utf-8">    <title>Listviewexample</title>    <!--WinJS references --    <link href="//microsoft.winjs.0.6/css/ui-light.css" rel="stylesheet">    <script src="//microsoft.winjs.0.6/js/base.js"></script>    <script src="//microsoft.winjs.0.6/js/ui.js"></script>    <!--listviewexample references --    <link href="/css/default.css" rel="stylesheet">    <script src="/js/default.js"></script>    <!--Your data file--    <script src="/js/dataexample.js"></script>>

Add the following code to the HTML page:

<div ID="Mediumlisticontexttemplate" Data-win-control="WinJS.Binding.Template">    <div style="width:150px; height:100px; ">        <!--Displays the "Picture" field.         src="#" style="width:60px; height:60px; "              Data-win-bind="Alt:title; Src:picture " />        <div>            <!--Displays the "title" field.             Data-win-bind="Innertext:title">>            <!--Displays the "Text" field.              Data-win-bind="Innertext:text">>        </div>    </div></div>       <div ID="Basiclistview" Data-win-control="WinJS.UI.ListView"     data-win-options="{itemDataSource:DataExample.itemList.dataSource, Itemtemplate:select (' #mediumListIconTextTemplate ')}"></div>

JS folder in the Dataexample.js JS file:

(function() {"Use strict";var DataArray= [    {title:"Basic Banana",text:"Low-fat Frozen Yogurt", Picture:"Images/60banana.png"},    {title:"Banana Blast",text:"Ice Cream", Picture:"Images/60banana.png"},    {title:"Brilliant Banana",text:"Frozen custard", Picture:"Images/60banana.png"},    {title:"Orange Surprise",text:"Sherbet", Picture:"Images/60orange.png"},    {title:"Original Orange",text:"Sherbet", Picture:"Images/60orange.png"},    {title:"Vanilla",text:"Ice Cream", Picture:"Images/60vanilla.png"},    {title:"Very Vanilla",text:"Frozen custard", Picture:"Images/60vanilla.png"},    {title:"Marvelous Mint",text:"Gelato", Picture:"Images/60mint.png"},    {title:"Succulent Strawberry",text:"Sorbet", Picture:"Images/60strawberry.png"}    ];var dataList=New WinJS.Binding.List(DataArray);//Create a namespace to make the data publicly    //accessible.    var publicmembers=        {itemList: DataList};WinJS.Namespace.Define("Dataexample", publicmembers); })();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.