【发布时间】:2023-03-19 21:11:02
【问题描述】:
我正在使用 listview 在 xamarin 表单中显示联系人号码。单击任何单元格时,我只想更改该特定单元格的内容。以下是我的代码:
lst_view.ItemSelected += async (object sender, SelectedItemChangedEventArgs e) =>
{
var con =(Contact)e.SelectedItem;
int index=contactList.IndexOf(con);
if (con.is_selected)
{
contactList[index].is_selected = false;
contactList[index].img = "";
}
else{
contactList[index].is_selected = true;
contactList[index].img = "selected_checkbox.jpeg";
}
lst_view.ItemTemplate = new DataTemplate(typeof(ContactsItemCell));
};
它工作正常,但最后我提供了新的数据模板,即单击单元格整个列表视图重绘,这是令人讨厌的体验。我只想更新那个单元格,而不是整个列表视图。顺便说一句,我正在通过与 valueconverter 绑定来更改该单元格的图像。
【问题讨论】: