ListView in ScrollView not scrolled

I have a RelativeLayout in ScrollView which contains ListView. When I want to scroll ListView scrolled RelativeLayout. But if I hold down ListView one finger, and scroll the other finger, it scrolled.

Answers

  • NMackayNMackay GBInsider, University mod
    edited November 2015

    I'm not sure why you would wrap a Listview in a scrollview when the Listview already takes care of the scrolling, that just causes all sorts of issues.

        <ContentPage Title="Orders" Icon="IconOrdersInd.png" Padding="2" Style="{StaticResource PageStyle}">
            <Grid x:Name="GridScanRootLayout">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="50" />
                    <RowDefinition Height="26" />
                </Grid.RowDefinitions>
    
                <RelativeLayout Grid.Row="0" Padding="2">
                    <telerikDataControls:RadListView BackgroundColor="#d5d4d3" x:Name="ListviewOrders"
                                                     IsItemSwipeEnabled="False"
                                                     SelectionChanged="ListviewScannedDocs_OnSelectionChanged"
                                                     ItemsSource="{Binding Orders}" SelectionMode="Multiple">
    

    For something like a data page that doesn't have a scrollview built in

    <ContentPage Title="BIO" Icon="Bio.png" Style="{StaticResource PageStyle}" Padding="2,4,2,2">
            <StackLayout Orientation="Vertical" VerticalOptions="FillAndExpand"
                         BackgroundColor="White">
                <ScrollView VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
    
  • @NMackay You can see my problem in attached file. It should clarify the situation. I hope for your help)

  • NMackayNMackay GBInsider, University mod

    I think in native Android (API21) you can have nested Listview within a scrollview, no idea about iOS but it's generally not a great idea. Also I don't know if forms supports this, probably not.

    Perhaps add the controls above and below into the Listview Header and Footer templates, I haven't tried it personally but it's a known workaround I believe.

  • DavidBritchDavidBritch GBXamarin Team Xamurai

    From https://developer.xamarin.com/guides/cross-platform/xamarin-forms/user-interface/listview/performance/

    Avoid placing a ListView inside a ScrollView for the following reasons:

    • The ListView implements its own scrolling.
    • The ListView will not receive any gestures, as they will be handled by the parent ScrollView.
    • The ListView can present a customized header and footer that scrolls with the elements of the list, potentially offering the functionality that the ScrollView was used for.
  • AhmedAlejoAhmedAlejo USMember ✭✭

    @DavidBritch > @DavidBritch said:

    • The ListView can present a customized header and footer that scrolls with the elements of the list, potentially offering the functionality that the ScrollView was used for.

    this actually leeds to another long standing bug 36285

  • @DavidBritch hi!

    Let me describe the screen a bit more. This is a shopping application and the screen is where the user chooses delivery options. We have several different parameters like delivery address, billing address, delivery time, package options and additional notes. So the screen itself is quite long, therefore we need to use ScrollView for it. On the other hand, we want to show addresses in ListView. In such way, the user will click on address option, see the ListView, scroll in it and choose the address. The ListView will close. Then he will scroll the main screen to navigate to further delivery options.

    So in this case the scroll in the ListView would not help user to see the rest of the screen.

    What would you recommend in this situation?

    thanks and regards

  • DavidBritchDavidBritch GBXamarin Team Xamurai

    Have you considered using the TableView? https://developer.xamarin.com/guides/cross-platform/xamarin-forms/user-interface/tableview/

    It's designed precisely for scenarios such as collecting data in a form.

  • @DavidBritch hi!

    Thank you for the reply. Just to clarify; which option do you recommend below?

    1) To use ScrollView for the screen and TableView for the fields where we use ListView today?

    2) To use TableView for the screen instead of ScrollView and keep using ListView for fields?

    3) To use only and only TableView?

  • DavidBritchDavidBritch GBXamarin Team Xamurai

    TableView handles scrolling, so you don't need to embed it in a ScrollView. You should be able to do what you want purely by using a TableView.

  • @DavidBritch I tried to use TableView. Maybe I did something wrong, but I was not able to realize the inner scroll. Only TableView scrolled

  • Abhijeet_SuryaAbhijeet_Surya USMember ✭✭✭

    @DavidBritch

    Thanks.

    I put list view in scroll view & was scratching my head why it is not working :smile: .....

Sign In or Register to comment.