我想在listview裏面創建listview。我試着下面的代碼,這是不工作在Android中,相同的代碼在iOS中完美工作listview裏面的listview Xamarin.Forms
<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這樣的控件。我綁定子列表視圖作爲父列表視圖的ItemsSource的一部分。上面的代碼不工作,它只顯示父級列表視圖,不顯示子列表視圖。
爲什麼它在Android上「不工作」?你可以再詳細一點嗎? – Demitrian