在 Xamarin.Forms 3.5 中,Microsoft 向我们介绍了可绑定布局,可用于动态填充布局(例如StackLayout、Grid等)。
在具有单列的网格中使用它非常简单:
<Grid BindableLayout.ItemsSource="{Binding Items}">
<BindableLayout.ItemTemplate>
<DataTemplate>
<Label Text="{Binding MyProperty}"/>
</DataTemplate>
</BindableLayout.ItemTemplate>
</Grid>
现在我的问题是如何使用它来填充具有多个列的网格,因为DataTemplate它只允许一个视图作为内容。当然,我可以在其中添加另一个Grid,但这将完全取消可绑定布局的价值Grid。