使用Xamarin表单创建Multiselect Listview(Xamarin跨平台) [英] Create Multiselect Listview with Xamarin Forms(Xamarin Cross Platform)

查看:104
本文介绍了使用Xamarin表单创建Multiselect Listview(Xamarin跨平台)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Listview的每个项目中实现一个带有Checkbox控件的Listview.如果要删除两个项目,我将检查这两个项目并单击Delete将其删除.还能在Github中找到单个演示示例.

I am trying to implement a Listview with Checkbox controll in each item of Listview.If I want to delete two items I will check those two items and click of delete it should delete.I explored more about this kind of concept but not able to find single demo example in Github as well.

编程语言:Xamarin表单不在Xamarin android或Xamain IOS中.我已经知道如何在这些平台上实现.但是我至少没有任何示例代码,以便更好地理解"Xamarin表单中的多选和删除操作"

Programming Language:Xamarin forms not in Xamarin android or Xamain IOS.I already know how to implement in those platforms.But I dont have any sample code at least to for better understanding of "Multiselect and deletion operation in Xamarin Forms"

推荐答案

  • 使用SwitchCell(此处的示例: https://github.com/xamarin/xamarin-forms-samples/tree/master/UserInterface/ListView/SwitchEntryTwoBinding/twoWayBinding ))
    • Use SwitchCell (example here: https://github.com/xamarin/xamarin-forms-samples/tree/master/UserInterface/ListView/SwitchEntryTwoBinding/twoWayBinding))
    • 或创建自定义ViewCell布局( https://developer.xamarin.com/guides/cross-platform/xamarin-forms/user-interface/listview/customizing-cell-appearance/-自定义单元格 >章节)

      or create custom ViewCell layout (https://developer.xamarin.com/guides/cross-platform/xamarin-forms/user-interface/listview/customizing-cell-appearance/ - Custom Cells chapter)

      • 使用您的ViewModel.ObservableCollection.IsChecked属性绑定SwitchCell.OnPropertyYourCustomViewCell.Checkbox.CheckedProperty(如SwitchEntryTwoBinding示例)

      • Bind SwitchCell.OnProperty or YourCustomViewCell.Checkbox.CheckedProperty with your ViewModel.ObservableCollection.IsChecked property (as in SwitchEntryTwoBinding example)

      然后您可以制作一个ButtonToolbarItem,该方法调用对ViewModel.ObservableCollection中的每个项目进行迭代的方法,并在IsChecked=true时将其删除.

      Then you could make a Button or ToolbarItem which calls method that iterates every item in ViewModel.ObservableCollection and deletes it if IsChecked=true.

      这篇关于使用Xamarin表单创建Multiselect Listview(Xamarin跨平台)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆