[英]How to bind collection of images in Xamarin Forms Cross-Platform
In WPF
, I can easily bind a collection of image sources to a WrapPanel
with image template for instance: 在WPF
,我可以轻松地将图像源集合绑定到具有图像模板的WrapPanel
,例如:
<ItemsControl ItemsSource="{Binding YourChildItems}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
I cannot find an alternative Cross-platform Xamarin Forms
way of binding my Image
collection to any panel based control. 我找不到将我的Image
集合绑定到任何基于面板的控件的替代Cross-platform Xamarin Forms
方式。
There is an equivalent of ItemsControl
in Xamarin.Forms labs called RepeaterView
. Xamarin.Forms实验室中有一个等效的ItemsControl
称为RepeaterView
。 It has support for item DataTemplate
as well as ItemsPanelTemplate. 它支持item DataTemplate
以及ItemsPanelTemplate。 Check the wiki page on GitHub and this forum thread for examples 查看GitHub上的Wiki页面以及此论坛主题以获取示例
WrapLayout.cs
. 转到此处并下载WrapLayout.cs
。 Then you should define its namespace in xaml 然后,您应该在xaml中定义其名称空间
xmlns:xf="clr-namespace:Xamarin.Forms"
You should use it like this code: 您应该像下面的代码一样使用它:
<ScrollView>
<xf:WrapLayout x:Name="wrp" />
</ScrollView>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.