我查看了Controls_ListViewWorkingWithDataSources MSDN示例,瞭解如何從WinJS.Binding.List中刪除一個項目,以下是他們的解決方案。請告訴我有一個更簡單的方法。從WinJS.Binding.List中刪除一個項目
if (list2.selection.count() > 0) {
list2.selection.getItems().done(function (items) {
//Sort the selection to ensure its in index order
items.sort(function CompareForSort(item1, item2) {
var first = item1.index, second = item2.index;
if (first === second) {
return 0;
}
else if (first < second) {
return -1;
}
else {
return 1;
}
});
//Work backwards as the removal will affect the indices of subsequent items
for (var j = items.length - 1; j >= 0; j--) {
// To remove the items, call splice on the list, passing in a count and no replacements
lettersList.splice(items[j].index, 1);
}
});
而Bam它的工作!謝謝,大師! –