0
私はXamarin Formsで非常に新しいので、簡単な例で学習しようとしています。今私はmasterdetailpageを持っていて、私はTextCellsのようなListViewとListViewアイテムでメニューアイテムを表示したいのですが、このようなXamlコードを書くとメニュー項目が表示されません。2つのTextCellがListView内にあります
<MasterDetailPage.Master>
<ContentPage BackgroundColor="AntiqueWhite" Title="Master" Icon="menuicon.png">
<ContentPage.Content>
<StackLayout VerticalOptions="Start" HorizontalOptions="Center" Margin="0,20,0,0">
<ListView BackgroundColor="Transparent" SeparatorVisibility="None" HasUnevenRows="True">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<TextCell x:Name="a" Text="Page 1" TextColor="Black" Tapped="TextCell_Tapped"></TextCell>
<TextCell x:Name="b" Text="Page 2" TextColor="Black" Tapped="TextCell_Tapped_1"></TextCell>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage.Content>
</ContentPage>
おかげで、すべての をコードお楽しみください!
ViewCellには1つの子しか持てません。その子をStackLayoutのようなコンテナにして、その内部に複数のコントロールを配置することができます。セルを互いに入れ子にすることはできません。 ListViewは、データバインドコントロールとしても使用されます。ハードコーディングされた項目のリストが必要な場合は、代わりに表を使用します。 – Jason