Win8 App使用Listview的簡單方法

來源:互聯網
上載者:User

標籤:style   tar   ext   width   strong   使用   

這是Win8 App神聖不可侵犯的標頭檔:

<head>    <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></head>

HTML頁面加入以下代碼:

<div id="mediumListIconTextTemplate" data-win-control="WinJS.Binding.Template">    <div style="width: 150px; height: 100px;">        <!-- Displays the "picture" field. -->        <img src="#" style="width: 60px; height: 60px;"              data-win-bind="alt: title; src: picture" />        <div>            <!-- Displays the "title" field. -->            <h4 data-win-bind="innerText: title"></h4>            <!-- Displays the "text" field. -->             <h6 data-win-bind="innerText: text"></h6>        </div>    </div></div>       <div id="basicListView" data-win-control="WinJS.UI.ListView"     data-win-options="{itemDataSource : DataExample.itemList.dataSource, itemTemplate: select(‘#mediumListIconTextTemplate‘)}"></div>

js檔案夾中dataExample.js中的js檔案:

(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); })();

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.