|
2 | 2 |
|
3 | 3 | This example demonstrates how to create a horizontal listview using Xamarin.Forms SfListView. |
4 | 4 |
|
| 5 | +## Sample |
| 6 | +```xaml |
| 7 | + <Grid> |
| 8 | + <Grid.RowDefinitions> |
| 9 | + <RowDefinition Height="Auto"/> |
| 10 | + <RowDefinition Height="Auto"/> |
| 11 | + </Grid.RowDefinitions> |
| 12 | + <Grid x:Name="headerGrid" BackgroundColor="#FFEEEEF2" HeightRequest="45"> |
| 13 | + <Label LineBreakMode="NoWrap" |
| 14 | + Text="Photo Gallery" FontAttributes="Bold" |
| 15 | + FontSize="16" TextColor="Black" HorizontalOptions="Center" VerticalOptions="Center"/> |
| 16 | + </Grid> |
| 17 | + <syncfusion:SfListView x:Name="listView" Orientation="Horizontal" Padding="10,10,10,10" |
| 18 | + SelectionMode="None" Grid.Row="1" |
| 19 | + ItemsSource="{Binding Gallerynfo}" |
| 20 | + ItemSpacing="3"> |
| 21 | + <syncfusion:SfListView.HeightRequest> |
| 22 | + <OnPlatform x:TypeArguments="x:Double"> |
| 23 | + <On Platform="Android"> |
| 24 | + <OnIdiom x:TypeArguments="x:Double" Phone="220" Tablet="220" /> |
| 25 | + </On> |
| 26 | + <On Platform="iOS"> |
| 27 | + <OnIdiom x:TypeArguments="x:Double" Phone="170" Tablet="280" /> |
| 28 | + </On> |
| 29 | + <On Platform="UWP"> |
| 30 | + <OnIdiom x:TypeArguments="x:Double" Desktop="220" Phone="200" Tablet="220" /> |
| 31 | + </On> |
| 32 | + <On Platform="macOS" Value="220"/> |
| 33 | + </OnPlatform> |
| 34 | + </syncfusion:SfListView.HeightRequest> |
| 35 | + |
| 36 | + <syncfusion:SfListView.ItemSize> |
| 37 | + <OnPlatform x:TypeArguments="x:Double"> |
| 38 | + <On Platform="Android"> |
| 39 | + <OnIdiom x:TypeArguments="x:Double" Phone="173" Tablet="180" /> |
| 40 | + </On> |
| 41 | + <On Platform="iOS"> |
| 42 | + <OnIdiom x:TypeArguments="x:Double" Phone="125" Tablet="250" /> |
| 43 | + </On> |
| 44 | + <On Platform="UWP"> |
| 45 | + <OnIdiom x:TypeArguments="x:Double" Desktop="170" Phone="160" Tablet="170" /> |
| 46 | + </On> |
| 47 | + <On Platform="macOS" Value="170"/> |
| 48 | + </OnPlatform> |
| 49 | + </syncfusion:SfListView.ItemSize> |
| 50 | + |
| 51 | + <syncfusion:SfListView.ItemTemplate> |
| 52 | + <DataTemplate> |
| 53 | + <Frame BackgroundColor="#EEEEEE" Padding="2"> |
| 54 | + <Frame.HasShadow> |
| 55 | + <OnPlatform x:TypeArguments="x:Boolean"> |
| 56 | + <On Platform="Android" Value="True"/> |
| 57 | + <On Platform="UWP" Value="True"/> |
| 58 | + <On Platform="iOS,macOS" Value="False"/> |
| 59 | + </OnPlatform> |
| 60 | + </Frame.HasShadow> |
| 61 | + <Grid RowSpacing="0" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"> |
| 62 | + <Grid.RowDefinitions> |
| 63 | + <RowDefinition Height="*" /> |
| 64 | + <RowDefinition Height="48" /> |
| 65 | + </Grid.RowDefinitions> |
| 66 | + <Image Source="{Binding Image}" Aspect="Fill"/> |
| 67 | + <Label Grid.Row="1" Text="{Binding ImageTitle}" |
| 68 | + LineBreakMode="WordWrap" |
| 69 | + HorizontalTextAlignment="Start" |
| 70 | + VerticalTextAlignment="Center" |
| 71 | + TextColor="Black" Opacity="0.87" |
| 72 | + Margin="16,0,0,0" FontSize="16"> |
| 73 | + </Label> |
| 74 | + </Grid> |
| 75 | + </Frame> |
| 76 | + </DataTemplate> |
| 77 | + </syncfusion:SfListView.ItemTemplate> |
| 78 | + </syncfusion:SfListView> |
| 79 | + </Grid> |
| 80 | +``` |
| 81 | + |
5 | 82 | See [How to create a horizontal listview in Xamarin.Forms](https://www.syncfusion.com/kb/9631/how-to-create-a-horizontal-listview-in-xamarin-forms) for more details. |
6 | 83 | ## <a name="requirements-to-run-the-demo"></a>Requirements to run the demo ## |
7 | 84 |
|
|
0 commit comments