我在 MvxListView 中有列表项和删除按钮。我想删除单击删除按钮的特定行。如何使用 Icommand实现该点击事件
答案 0 :(得分:0)
将MvxListView
扩展为DeleteClick
属性:
ICommand DeleteClik;
将此属性绑定到您想要的命令:
local:MvxBind="DeleteClick MyDeleteCommand"
创建一个自定义适配器,该适配器将引用此DeleteClick
命令并将其绑定到GetView
方法上的查看点击事件:
public override View GetView (int position, View view, ViewGroup parent)
{
//TODO: Ensure view is not null, call base method and convert to proper type
var deleteButton = view.FindViewById<Button>(Resource.Id.buttonId);
deleteButton.Click += (sender, e) => {
if(_deleteCommand != null && _deleteCommand.CanExecute())
{
//TODO: Cast to your type
_deleteCommand(GetRawItem(position));
}
}
}