Button on ListItem Listview using Icommand

I have Listitems with a delete button in an MvxListView . I want to remove the articular line in which the delete button is clicked. How to implement this click event using Icommand

+4
source share
1 answer

Extend MvxListView to have the DeleteClick property:

ICommand DeleteClik;

Bind this property to the required command:

 local:MvxBind="DeleteClick MyDeleteCommand" 

Create a custom adapter that will reference this DeleteClick command and bind it to the click view event using the GetView method:

 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)); } } } 
0
source

All Articles