zoukankan      html  css  js  c++  java
  • Win8 App使用Listview的简单方法

    这是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=" 150px; height: 100px;">
    
            <!-- Displays the "picture" field. -->
            <img src="#" style=" 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); 
    
    })();
  • 相关阅读:
    URL传递的参数是UTF-8编码,在打开的页面正常显示(GB2312)的方法
    JS windows.open打开窗口并居中
    一个tomcat如何部署多个项目运行
    redis 服务配置开机自启动
    解决端口被占用问题
    MySQL中concat以及group_concat的使用
    java 使用OpenOffice文件实现预览
    eclipse安装maven插件
    数据库三范式
    mysql 查询的字段值太长显示不全 group_concat
  • 原文地址:https://www.cnblogs.com/axl234/p/3772174.html
Copyright © 2011-2022 走看看