简体   繁体   English

如何在Xamarin Forms中的另一个列表中获取列表并将其绑定到ListView中?

[英]How to fetch list inside of another list and bind it inside ListView in Xamarin Forms?

I want to show one list which is inside of another list in Xamarin.Forms. 我想显示一个列表,该列表位于Xamarin.Forms中另一个列表的内部。 I have JSON structured like the following: 我的JSON结构如下:

 [
   {
     "CategoryName": "Tea",
      "SubCategories" :
      [
       {
       "SubCategoryName": "GreenTea",
       }
      ] 
   }
 ] 

My JSON looks like this. 我的JSON看起来像这样。 I am able to bind outer list which is CategoryName list to list view but now I want to show SubCategoryName under CategoryName . 我可以将外部CategoryNameCategoryName列表)绑定到列表视图,但是现在我想在CategoryName下显示SubCategoryName I am using expandable view here. 我在这里使用展开视图。

Can anyone tell me how can I achieve this? 谁能告诉我如何做到这一点?

You can use ListView Grouping, there are many tutorials how to do it, like this article , or this code preview . 您可以使用ListView分组,有很多教程如何做到这一点,例如本文或此代码预览 James Montemagno did a great article too 詹姆斯·蒙特马格诺(James Montemagno)的文章很棒

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM