Xamarin Listview的List< List> [英] Xamarin listview of List<List>

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

问题描述

我正在制作一个移动应用程序,并且试图在列表视图中加载列表.该列表包含多个元素和一个列表:

I'm making a mobile app and I'm trying to load a list in a listview. The list has multiple elements and a list:

public static List<Proposition> PropositionList = new List<Proposition>
{
    new Proposition{
        PropositionId = Guid.Parse("00000000-0000-0000-0000-000000000001"),
        Place= "Barge",
        Date= new DateTime(2020, 7, 11),
        Users= new List<User>(){
            new User
            {
                UserId = Guid.Parse("00000000-0000-0000-0000-000000000001"),
                Name= "Jan Aerts",
                Sterren = 3
            },
            new User
            {
                UserId = Guid.Parse("00000000-0000-0000-0000-000000000002"),
                Naam = "Bart Denys",
                Sterren = 5
            }
        }
    }
}

如何使用x:Name ="StacklayoutMap"在我的stacklayout中从Users.Name列出列表?

How do I make a list from Users.Name in my stacklayout with x:Name="StacklayoutMap"

<ListView x:Name="lvPropositions" HasUnevenRows="True">
    <ListView.ItemTemplate>
        <DataTemplate>
             <ViewCell>
                 <Frame BorderColor="Black" Margin="10, 0, 10, 0" CornerRadius="45">
                     <StackLayout StyleClass="listitem" Padding="5">
                         <StackLayout Orientation="Horizontal">
                              <Label Style="{DynamicResource DivesLabelStyle}" Text="{Binding Datum}" VerticalOptions="Center" HorizontalOptions="StartAndExpand" />
                              <Label Style="{DynamicResource DivesLabelStyle}" Text="{Binding Plaats}" VerticalOptions="Center" HorizontalOptions="EndAndExpand" />
                         </StackLayout>
                         <StackLayout Orientation="Horizontal">
                             <StackLayout x:Name="StackLayoutMap">
                                
                              </StackLayout>
                              <ImageButton Source="addBlack.png" BackgroundColor="Transparent" HorizontalOptions="EndAndExpand" VerticalOptions="Center" Clicked="BtnRegister_Clicked"/>
                          </StackLayout>
                     </StackLayout>
                </Frame>
         </ViewCell>
     </DataTemplate>
</ListView.ItemTemplate>

推荐答案

您可以使用可绑定的布局

 <StackLayout Orientation="Horizontal">
     <StackLayout x:Name="StackLayoutMap" BindableLayout.ItemsSource="{Binding Users}">
            <BindableLayout.ItemTemplate>
                <DataTemplate>

                    <Label Text="{Binding Naam}" TextColor="Red" ... />

                </DataTemplate>
            </BindableLayout.ItemTemplate>                     
     </StackLayout>
//...
</StackLayout>

有关可绑定布局的更多详细信息,您可以参考此

For more details about Bindable Layout you could refer this doc .

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

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