List 如何重新加载WinJS列表
我想创建一个列表,在一个事件(拍一张照片)之后,它会自动增长。我的意思是实时地将每张照片添加到列表中,这是我的方法List 如何重新加载WinJS列表,list,runtime,winjs,List,Runtime,Winjs,我想创建一个列表,在一个事件(拍一张照片)之后,它会自动增长。我的意思是实时地将每张照片添加到列表中,这是我的方法 //Invoke the camera capture UI for snapping a photo function imageCapture() { ... //Creates the array, datalist and the namespace for making this data public
//Invoke the camera capture UI for snapping a photo
function imageCapture() {
...
//Creates the array, datalist and the namespace for making this data public
if (dataArray == null) { dataArray = new Array(); }
dataArray[captureCount] = { title: capturedItem.name, id: "img" + captureCount, picture: photoBlobUrl };
var dataList = new WinJS.Binding.List(dataArray);
var publicMembers = { itemList: dataList };
WinJS.Namespace.define("DataExample", publicMembers);
}
这是加载内容的HTML页面
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta charset="utf-8" />
<title>eCamera</title>
<!-- Referencias de WinJS -->
<link href="//Microsoft.WinJS.1.0/css/ui-dark.css" rel="stylesheet" />
<script src="//Microsoft.WinJS.1.0/js/base.js"></script>
<script src="//Microsoft.WinJS.1.0/js/ui.js"></script>
<!-- Referencias de eCamera2 -->
<link href="/css/default.css" rel="stylesheet" />
<script src="/js/default.js"></script>
</head>
<body >
<div id="content">
<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 "id" field. -->
<h6 data-win-bind="innerText: id"></h6>
</div>
</div>
</div>
<div id="basicListView"
data-win-control="WinJS.UI.ListView"
data-win-options="{ itemDataSource : DataExample.itemList.dataSource,
itemTemplate: select('#mediumListIconTextTemplate'),
itemsDraggable: true,
itemsReorderable: true }"></div>
</div>
</body>
</html>
埃卡梅拉
如果我一开始将所有内容加载到一个固定的数据数组中,它就工作得很好,但是每次拍照时都要手动添加元素并进行设置,到目前为止都不起作用,如何让它工作
提前感谢您的支持应用程序不应每次都创建新列表。使用方法追加或拼接可用于插入。由于列表是可观察的,用户界面将自动更新列表的更改(删除/添加)