简体   繁体   English

如何在Xamarin Forms跨平台中绑定图像集合

[英]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页面以及此论坛主题以获取示例

  1. Go to here and download WrapLayout.cs . 转到此处并下载WrapLayout.cs
  2. Add it your project in Visual Studio. 将其添加到Visual Studio中的项目。
  3. Then you should define its namespace in xaml 然后,您应该在xaml中定义其名称空间

    xmlns:xf="clr-namespace:Xamarin.Forms"

  4. You should use it like this code: 您应该像下面的代码一样使用它:

<ScrollView>
     <xf:WrapLayout x:Name="wrp" />   
</ScrollView>
  1. Finally you can add items in code behind. 最后,您可以在代码后面添加项目。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 用于跨平台Xamarin Forms的UserControl - UserControl for cross-platform Xamarin Forms 如何重命名Xamarin跨平台应用程序? - How to rename a Xamarin Cross-Platform App? 无法绑定继承的属性(Xamarin跨平台应用程序) - Can't bind inherited property (Xamarin Cross-Platform app) 如何从 Xamarin Forms 在 a.xaml 文件中获取跨平台应用程序中的可用屏幕尺寸值? - How to Get The Avaible Screen Size Value In Cross-Platform App From Xamarin Forms in a .xaml File? Xamarin中的跨平台OpenGL渲染 - Cross-platform OpenGL rendering in Xamarin 使用 __ANDROID__ 在跨平台库中编写的代码不会在 Xamarin forms 应用程序中执行 - Code written in Cross-platform library with __ANDROID__ does not execute in Xamarin forms application 在 Xamarin.Forms 跨平台应用程序中使用 Amazon Cognito 用户池进行身份验证 - Authentication with Amazon Cognito User Pools in Xamarin.Forms Cross-Platform App 创建Xamarin.Forms跨平台应用程序时出现“此项目需要Visual Studio更新才能加载”错误 - “This project requires a Visual Studio update to load” error when creating a Xamarin.Forms Cross-Platform Application 创建Xamarin.Forms跨平台应用程序时,“此项目需要加载Visual Studio更新”错误 - “This project requires a Visual Studio update to load” error when creating a Xamarin.Forms Cross-Platform Application 使用MediaPlugin(跨平台)选择多个图像 - Select multiple images with MediaPlugin (Cross-platform)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM