Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Horizontal ListView Xamarin.Forms

Is any way to create ListView with horizontal scroll in Xamarin.Forms like image

ListView Horizontal

this is what i have done for vertical

var myListView = new ListView {     ItemTemplate = new DataTemplate(typeof(ImageCell)) }; 
like image 857
Luigi Saggese Avatar asked Jun 20 '14 14:06

Luigi Saggese


People also ask

What is the difference between ListView and CollectionView in Xamarin forms?

CollectionView and ListView differencesCollectionView has a flexible layout model, which allows data to be presented vertically or horizontally, in a list or a grid. CollectionView supports single and multiple selection. CollectionView has no concept of cells.

How do I use CarouselView in Xamarin forms?

CarouselView is available in Xamarin. Forms 4.3. However, it is currently experimental and can only be used by adding the following line of code to your AppDelegate class on iOS, or to your MainActivity class on Android, before calling Forms.

What is ListView in Xamarin forms?

ListView is a view for presenting lists of data, especially long lists that require scrolling. CollectionView is a view for presenting lists of data using different layout specifications. It aims to provide a more flexible, and performant alternative to ListView . For more information, see Xamarin.


2 Answers

As of Xamarin Forms 2.3 CarouselView does just that, and more. Read more here.

<ContentView HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">   <CarouselView ItemsSource="{Binding MyDataSource}">     <CarouselView.ItemTemplate>       <DataTemplate>         <Label Text="{Binding LabelText}" />       </DataTemplate>     </CarouselView.ItemTemplate>   </CarouselView> </ContentView> 
like image 187
Korayem Avatar answered Sep 20 '22 07:09

Korayem


Yes, you technically can. Set the Rotation to 270 (all VisualElements have a Rotation BindableProperty). However, this looks like a suboptimal solution as there are white spaces at the top and bottom and you have to drag the view left and right to see everything fully.

public static readonly BindableProperty RotationProperty; public static readonly BindableProperty RotationXProperty; public static readonly BindableProperty RotationYProperty; 

The code above is from the VisualElement class. The code below is a small sample of my own.

                                              ∨∨∨                                                   <ListView x:Name="MessagesListView" Rotation="270" ItemsSource="{Binding Items}" RowHeight="40">   <ListView.ItemTemplate>     <DataTemplate>       <ViewCell>         <ViewCell.View>           <StackLayout>             <!--mylayouthere-->           </StackLayout>         </ViewCell.View>       </ViewCell>     </DataTemplate>   </ListView.ItemTemplate> </ListView> 
like image 25
Millie Smith Avatar answered Sep 22 '22 07:09

Millie Smith