0
votes

I have a custom list view with horizontal scrolling, am binding data to the listview through view model binding . But in the runtime the list view is not updating when the observable collection changed.I tried with xamarin forms list view that is working perfectly but the custom list view is not working.

I implemented custom list view with the help of this link:- Xamarin, Is there any way a listview can be used horizontally?

1
The code you are linking for your Horizontal ListView, is in fact a ScrollView, so it is not designed to listen to any data changes. If you want that behavior you have to implement yourself, the event subscription on any ObservableCollection data changeMiiite
Is there any code or sample solutions ?Aswathy K R
Well since Xamarin.Forms is open source I suggest you go take a look at the ListView source code in their repositoryMiiite
CollectionView supports horizontal orientation and databindingJason

1 Answers

1
votes

You can use CollectionView in Forms if you want to let the list scroll in horizontal .

<CollectionView ItemsSource="{Binding xxx}">
    <CollectionView.ItemsLayout>
        <ListItemsLayout Orientation="Horizontal" />
    </CollectionView.ItemsLayout>

     <CollectionView.ItemTemplate>
        <DataTemplate>

          //...
        </DataTemplate>
    </CollectionView.ItemTemplate>

</CollectionView>

Don't forget to adding the following line of code to your AppDelegate class on iOS, or to your MainActivity class on Android, before calling Forms.Init:

Forms.SetFlags("CollectionView_Experimental");