C# 如何在Xamarin.forms中的ListView中显示ListView
我的响应数据类似于以下虚拟数据:C# 如何在Xamarin.forms中的ListView中显示ListView,c#,listview,xamarin,xamarin.forms,C#,Listview,Xamarin,Xamarin.forms,我的响应数据类似于以下虚拟数据: { "MsgCode": null, "IsError": false, "IsPartialError": false, "Message": [], "Data": { "TrackUpdates": [{ "VersionId": 3, "VersionNumber": "15.2", "Published
{
"MsgCode": null,
"IsError": false,
"IsPartialError": false,
"Message": [],
"Data": {
"TrackUpdates": [{
"VersionId": 3,
"VersionNumber": "15.2",
"PublishedDate": "2020-01-20T00:00:00.000Z",
"UpdatesName": [{
"UpdateId": 4,
"UpdateName": "Login issue fixes"
},
{
"UpdateId": 3,
"UpdateName": "Profile added"
}
]
},
{
"VersionId": 2,
"VersionNumber": "15.1",
"PublishedDate": "2019-12-15T00:00:00.000Z",
"UpdatesName": [{
"UpdateId": 2,
"UpdateName": "Token related changes"
},
{
"UpdateId": 1,
"UpdateName": "Design updates"
}
]
}
]
},
"Pagination": null
}
如何使用xamarin表单显示此内容
主要问题是显示内部列表。如果存在格式问题,请检查此图像。
我想您可以在Listview中使用Listview,如下所示
<ListView x:Name="contactList" ItemsSource="{Binding PlatformsList}" SeparatorVisibility="Default"
VerticalOptions="Center" HorizontalOptions="Center" WidthRequest="150">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout>
<Label Text="Nested List" />
<ListView x:Name="contactNestedList" ItemsSource="{Binding BindingContext.PlatformsList, Source={x:Reference contactList}}" HeightRequest="300" BackgroundColor="Yellow" WidthRequest="150">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal">
<CheckBox IsChecked="{Binding IsChecked}" VerticalOptions="Center" />
<Label TextColor="Red" Margin="10,0" Text="{Binding PlatformName}" IsEnabled="{Binding IsChecked}" VerticalOptions="Center" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
但是,不建议在ListView中使用ListView。如果在这种情况下,如果您的嵌套列表是一个只包含一组固定项的已定义列表,那么您可以使用BindableLayout而不是嵌套的Listview。i、 只需将父ListView中的ListView替换为BindableLayout
如果您对使用BindableLayout有任何疑问,请查看我下面的博客以了解更多信息
我希望它有帮助…使用分组列表视图如果我的答复对您有帮助,请记住将我的答复标记为答复。谢谢