【问题标题】:How to bind collection of images in Xamarin Forms Cross-Platform如何在 Xamarin Forms Cross-Platform 中绑定图像集合
【发布时间】:2015-11-05 06:54:00
【问题描述】:

WPF 中,我可以使用图像模板轻松地将一组图像源绑定到WrapPanel

<ItemsControl ItemsSource="{Binding YourChildItems}">
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <WrapPanel/>
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
</ItemsControl>

我找不到将我的Image 集合绑定到任何基于面板的控件的替代Cross-platform Xamarin Forms 方式。

【问题讨论】:

标签: c# wpf xaml binding xamarin-forms


【解决方案1】:

在 Xamarin.Forms 实验室中有一个等效的 ItemsControl,称为 RepeaterView。它支持项目DataTemplate 以及ItemsPanelTemplate。查看 GitHub 上的 wiki page 和此 forum thread 以获取示例

【讨论】:

  • 感谢您告知RepeaterView。我不知道。
【解决方案2】:
  1. 到这里下载WrapLayout.cs

  2. 在 Visual Studio 中将其添加到您的项目中。

  3. 那么你应该在 xaml 中定义它的命名空间

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

  4. 你应该像这样使用它:

<ScrollView>
     <xf:WrapLayout x:Name="wrp" />   
</ScrollView>
  1. 终于可以在代码后面添加项目了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-06-24
    • 1970-01-01
    • 2020-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-25
    相关资源
    最近更新 更多