简体   繁体   English

如何通过索引从 xamarin 形式的 ListView 对象获取访问视单元?

[英]How to get access viewcell by index from ListView object in xamarin forms?

I want to get Viewcell (view) of listview in xamarin forms by index, i tried a lot as below code我想通过索引以 xamarin 形式获取列表视图的Viewcell (视图),我尝试了很多如下代码

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

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

I found the workaround to get the viewcell by passing item index, not the better way but this works if we dont have any alternate.我找到了通过传递项目索引来获取视单元的解决方法,这不是更好的方法,但如果我们没有任何替代方法,这可行。

MyListView.NotifyRowTapped(selectedTimeCardIndex);

 private void ViewCellTapped(object sender, EventArgs args)
 {
   if(sender is ViewCell viewCell)
   {
     //viewCell for the selected index
   } 
 }

I just got solution of this problem by myself while using ITemplatedItemsView interface by customising the ListView我刚刚通过自定义 ListView 在使用ITemplatedItemsView界面时自己解决了这个问题

For more discussion visit Here更多讨论请访问这里

    public class CustomViewCell: ListView
   {

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

Implementation :执行 :

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从 Xamarin Forms 中的自定义 ViewCell 获取 ListView 项目索引? - How to get ListView item index from custom ViewCell in Xamarin Forms? Xamarin Forms ListView:访问ViewCell的对象数据 - Xamarin Forms ListView: Access to ViewCell's Object data Xamarin.Forms中如何获取ListView的ViewCell数据并发送到另一个页面 - How to get ListView's ViewCell data and send it to another page in Xamarin.Forms 如何在ListView Xamarin Forms中创建舍入的第一个和最后一个视单元? - How to create a rounded first and last viewcell in ListView Xamarin Forms? 如何从 xamarin forms 中的列表视图中获取所选项目索引? - How to get the selected item index from the listview in xamarin forms? Xamarin Forms - ListView 中的 iOS 动态 ViewCell 大小 - Xamarin Forms - iOS dynamic ViewCell size in a ListView Xamarin.forms:如何从 Listview 获取对象值 - Xamarin.forms: How to get Object value from a Listview 如何在Xamarin Forms中的视单元中绑定堆栈布局? - How to bind a stacklayout in a viewcell in Xamarin Forms? 创建列表后,如何更新Xamarin Forms ListView的ViewCell属性? - How can I update a Xamarin Forms ListView's ViewCell properties after the list has been created? 如何将事件从ViewCell传递到放置ListView的父对象 - How to pass event from ViewCell to parent object, where ListView is placed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM