c# - 当用户在 Xamarin.Forms 中同时单击多个项目时,如何修复 CollectionView SelectionMode="Single" 错误?
问题描述
我在 Xamarin.Forms 的 CollectionView 中使用 SelectionMode="Single",但每当用户不小心同时单击或点击多个项目时,它都会使我的应用程序崩溃。我尝试在 SelectionChangedCommand 和 SelectedItem 周围使用 try{}catch{},但它仍然没有帮助。应用程序崩溃后我可以在 Visual Studio 中找到的错误是“System.ArgumentOutOfRangeException:'索引超出范围。必须是非负数并且小于集合的大小。参数名称:索引'”我该如何解决这个?
#MyCollectionViewCode:
<CollectionView ItemsSource="{Binding Content}" ItemsUpdatingScrollMode="KeepItemsInView"
SelectionMode="Single" SelectedItem="{Binding SelectedData}"
SelectionChangedCommand="{Binding DoDisplay}"
ItemTemplate="{StaticResource dataTemplateSelector}"
/>
解决方案
推荐阅读
- java - Huawei ML Kit - Image Segmentation App 更新到 3.0.0.301 时崩溃
- multiprocessing - 提升已从消息队列中读取的进程的进程间返回 ID
- python - django-allauth 注册错误:文件名必须是 str 或 bytes 对象,或文件
- python - 读/写镶木地板时火花簇的问题
- java - HttpURLConnection 不抛出超时异常
- c - 如何将 X11 和 GLIBC 与 node-gyp 正确链接?
- ios - 如何使用 ionic config.xml 或 azure DevOps 任务从权利中删除未使用的 iCloud 密钥?
- java - 从配置服务器 Spring boot 访问属性文件时“发现脏文件”出现此错误
- aggregate - 业务对象:在 month_week 级别聚合计算度量
- oauth-2.0 - ADFS 2016 错误 MSIS7065 路径 adfs/oauth2/token 上没有注册的处理程序