eYe
eYe

Reputation: 1733

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:

<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.

Upvotes: 1

Views: 1430

Answers (2)

Mahdi Ataollahi
Mahdi Ataollahi

Reputation: 5202

  1. Go to here and download WrapLayout.cs.

  2. Add it your project in Visual Studio.

  3. Then you should define its namespace in 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.

Upvotes: 0

cleftheris
cleftheris

Reputation: 4839

There is an equivalent of ItemsControl in Xamarin.Forms labs called RepeaterView. It has support for item DataTemplate as well as ItemsPanelTemplate. Check the wiki page on GitHub and this forum thread for examples

Upvotes: 1

Related Questions