Skip to content

Instantly share code, notes, and snippets.

@Korayem
Last active May 30, 2016 11:30
Show Gist options
  • Save Korayem/1bf11450a99b742657f537b68e5f5952 to your computer and use it in GitHub Desktop.
Save Korayem/1bf11450a99b742657f537b68e5f5952 to your computer and use it in GitHub Desktop.
XAML
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="MobileApp.MyPage" xmlns:hsl="clr-namespace:mcpNetwork.Components.Forms;assembly=mcpnetwork.horizontalScrollLayout">
<ContentPage.Content>
<StackLayout Padding="0" Spacing="0">
<hsl:HorizontalScrollLayout x:Name="hscroll" HeightRequest="80" MultiSelection="false" ItemSelected="OnItemSelected">
<hsl:HorizontalScrollLayout.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout Spacing="0">
<Image Source="{Binding Image}" HeightRequest="100" WidthRequest="100" />
<StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand">
<Label Text="{Binding Name}" FontSize="11" HorizontalOptions="FillAndExpand" WidthRequest="50" LineBreakMode="WordWrap" />
<Label Text="{Binding Description}" FontSize="11" HorizontalOptions="EndAndExpand" />
</StackLayout>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</hsl:HorizontalScrollLayout.ItemTemplate>
</hsl:HorizontalScrollLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>
Code behind:
public partial class MyPage : ContentPage
{
public MyPage()
{
InitializeComponent();
hscroll.ItemSource = loadFromDataSource();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment