Listview Xamarin.Forms内部的Listview [英] Listview inside listview Xamarin.Forms

查看:55
本文介绍了Listview Xamarin.Forms内部的Listview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在listview中创建listview.我尝试了下面的代码,该代码在Android中不起作用,相同的代码在iOS中完美运行

I want to create listview inside listview. I tried below code, which is not working in Android, same code working perfectly in iOS

<local:CustomListview
          x:Name="ListView"
      ItemsSource="{Binding List1}" HasUnevenRows="True"
          >
          <local:CustomListview.ItemTemplate>
            <DataTemplate>
              <ViewCell>
                <StackLayout
                Orientation="Vertical">
                  <StackLayout Orientation="Horizontal">
                    <Label Text="{Binding Name}"></Label>
                    <Label Text="{Binding CreatedOn}"></Label>
                  </StackLayout>
                  <Label Text="{Binding Description}"></Label>

                  <StackLayout
                    Orientation="Horizontal"
                    >
                    <Label Text="{Binding Count}"></Label>
                    <Label Text="Likes(s)"></Label>
                  </StackLayout>

                    <StackLayout
                      Orientation="Vertical"
                      Padding="5, 0, 0, 0"
                    >
                        <local:CustomListview ItemsSource="{Binding List2}" HasUnevenRows="True">
                         <local:CustomListview.ItemTemplate>
                                <DataTemplate>
                                  <ViewCell>
                                    <StackLayout Orientation="Vertical">
                                      <Label Text="{Binding Description}"></Label>
                                      <StackLayout Orientation="Horizontal">
                                        <Label Text="{Binding CreatedBy}"></Label>
                                        <Label Text="{Binding CreatedOn}"></Label>
                                      </StackLayout>
                                    </StackLayout>
                                  </ViewCell>
                                </DataTemplate>
                         </local:CustomListview.ItemTemplate>
                      </local:CustomListview>
                    </StackLayout>      

                </StackLayout>
              </ViewCell>
            </DataTemplate>
          </local:CustomListview.ItemTemplate>


        </local:CustomListview>

有什么建议吗?

我不能使用组列表视图,因为我需要以特殊方式排列诸如Label之类的控件.我将子级listview绑定为父级listview的ItemsSource的一部分.上面的代码不起作用,其仅显示父级列表视图,子级列表视图未显示.

I can't use group listview, since I need to arrange controls like Label in particular way. I am binding child listview as part of parent listview's ItemsSource. Above code is not working, its showing only parent listview, child listview is not displayed.

推荐答案

Listview中的Listview不是受支持的选项.列表视图被设计为页面上唯一的根控件,这主要是由于尺寸和滚动方面的考虑.

Listview inside a Listview is not a supported option. Listviews are designed to be the only root control on a page, mainly due to sizing and scrolling concerns.

页面的复杂性也可能导致性能下降.

Also the complexity of the page might cause poor performance.

理想情况下,我建议您修改布局,以使重复的信息在另一页上.但是,如果您想继续使用这种方法,则应查看 RepeaterView 在XLabs中.它基本上是增强的StackLayout.

Ideally I would suggest reworking your layout so that the repeated information is on another page. However if you want to continue on with this approach you should look at the RepeaterView in XLabs. Its basically an enhanced StackLayout.

这篇关于Listview Xamarin.Forms内部的Listview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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