如何通过索引从 xamarin 形式的 ListView 对象获取访问视单元? [英] How to get access viewcell by index from ListView object in xamarin forms?

查看:28
本文介绍了如何通过索引从 xamarin 形式的 ListView 对象获取访问视单元?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过索引以 xamarin 形式获取列表视图的 Viewcell(视图),我尝试了很多如下代码

I want to get Viewcell(view) of listview in xamarin forms by index, i tried a lot as below code

var myViewCellList = mListView.ItemTemplate.values; 
//this return Dictionary with 0 elements

它可能看起来像var view = mListView.ItemTamplate[index];

推荐答案

我刚刚通过自定义 ListView 使用 ITemplatedItemsView 界面时自己解决了这个问题

I just got solution of this problem by myself while using ITemplatedItemsView interface by customising the ListView

有关更多讨论,请访问此处

    public class CustomViewCell: ListView
   {

       public ITemplatedItemsList<Cell> TemplatedItem
       {
           get { return ((ITemplatedItemsView<Cell>)this).TemplatedItems; }
       }        
   }

实现:

var viewcell = (CustomViewCell.TemplatedItem[0] as viewcell);

这篇关于如何通过索引从 xamarin 形式的 ListView 对象获取访问视单元?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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