我找到了如何使用以下代码从列表视图中删除项目:
var video = document.getElementById("myVideo");
var prevBuffer = {
"buffer": null,
"time": null
};
var isBuffering = function(){
if(video && video.buffered && video.buffered.end && video.buffered.length > 0){
var buffer = video.buffered.end(0);
var time = video.currentTime;
// Check if the video hangs because of issues with e.g. performance
if(prevBuffer.buffer === buffer && prevBuffer.time === time && !video.paused){
return true;
}
prevBuffer = {
"buffer": buffer,
"time": time
};
// Check if video buffer is less
// than current time (tolerance 3 sec)
if((buffer - 3) < time){
return true;
}
}
return false;
};
video.addEventListener("play", function(e){
// Make sure this handler is only called once
e.target.removeEventListener(e.type, arguments.callee);
// Give browsers 3secs time to buffer
setTimeout(function(){
// As "progress", "stalled" or "waiting" aren't fired
// reliable, we need to use an interval
var interval = setInterval(function(){
if(isBuffering()){
clearInterval(interval);
console.log("Buffering");
}
}, 500);
}, 3000);
});
但正如您在每次输入添加到private void buttonDelete_Click(object sender, EventArgs e) {
if (listViewStudents.SelectedItems != null) {
foreach (ListViewItem eachItem in listViewStudents.SelectedItems) {
listViewStudents.Items.Remove(eachItem);
ClearandFocus();
}
}
}
时在下面的代码中看到的那样,它也会被添加到带有ListView
Repository.AddStudent(student)
我想要实现的目标如下:每次点击删除按钮时,我希望在列表视图和列表中删除所选项目。我已经完成了几次尝试,但似乎无法完成这项工作,我想知道这是否可行?
答案 0 :(得分:0)
同步两个列表并非易事,不建议这样做。
请考虑将您的学生列表设为ObservableCollection<>
,并将其设置为ItemsSource
的{{1}}。集合中的更改将反映在您ListView
中。