0

I am putting a scroll view within a list view which is not working properly; it gets stuck sometimes. I changed the VerticalOptions property, but it scrolls for movement and then gets stuck.

This is my markup:

<ListView RowHeight="70" ItemTapped="ListView_ItemTapped" Margin="15,10" HasUnevenRows="True"  SeparatorVisibility="None" ItemsSource="{Binding InteractionsHistory}">
<ListView.ItemTemplate>
    <DataTemplate>
        <ViewCell >
            <StackLayout BackgroundColor="White"  
                                     Orientation="Horizontal" 
                                     HorizontalOptions="FillAndExpand" 
                                     VerticalOptions="FillAndExpand"
                                     Margin="0,0,0,10">
                <Grid  HorizontalOptions="FillAndExpand" RowSpacing="1" Margin="0,5,0,0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="25" />
                        <RowDefinition Height="1" />
                        <RowDefinition Height="100"/>
                        <RowDefinition Height="1" />
                        <RowDefinition Height="30" />
                    </Grid.RowDefinitions>
                    <StackLayout  Grid.Row="0" Orientation="Horizontal" Margin="5,0,5,0" >
                        <local:ImageCircle Aspect="AspectFill" VerticalOptions="Center" Source="{Binding ChannelImg}"  WidthRequest="25" HeightRequest="25"/>
                        <Label Text="{Binding InteractionAddedBy}" Style="{StaticResource lblCommonVewCase}" HorizontalOptions="FillAndExpand"/>
                        <Label Text="{Binding CreatedDate}" HorizontalOptions="EndAndExpand" Style="{StaticResource lblCommonVewCase}"/>
                    </StackLayout>
                    <StackLayout Margin="5,0,5,0" Style="{StaticResource CommonStackLayout}" Grid.Row="1"></StackLayout>
                    <ScrollView  Margin="10,10,10,0" Grid.Row="2"  VerticalOptions="Fill" Orientation="Vertical" HorizontalOptions="Fill" BackgroundColor="AliceBlue" >
                        <Label  Text="{Binding InteractionDesc}" VerticalOptions="FillAndExpand" Style="{StaticResource lblCommonVewCase}"/>
                    </ScrollView>
                    <StackLayout Margin="5,0,5,0" IsVisible="{Binding IsAttachmentVisible}"  Style="{StaticResource CommonStackLayout}" Grid.Row="3"></StackLayout>
                    <StackLayout Grid.Row="4" VerticalOptions="Center" Orientation="Horizontal" Margin="15,0" Padding="0,5" 
                                                 IsVisible="{Binding IsAttachmentVisible}" BackgroundColor="White">
                        <Image Source="attach.png" HeightRequest="15" WidthRequest="15" VerticalOptions="Center"/>
                        <Label Text="Attachments" Style="{StaticResource lblCommonVewCase}" VerticalOptions="Center"/>
                        <StackLayout.GestureRecognizers>
                            <TapGestureRecognizer Tapped="ViewAttach_Tapped" CommandParameter="{Binding .}"></TapGestureRecognizer>
                        </StackLayout.GestureRecognizers>
                    </StackLayout>
                </Grid>
            </StackLayout>
        </ViewCell>
    </DataTemplate>
</ListView.ItemTemplate>
</ListView>
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
priya_d
  • 393
  • 4
  • 24
  • The usage of using a ScrollView in a ListView or the other way around is highly discouraged because it can cause weird behavior, like this. I would recommend you to find another way to solve your problem. – Gerald Versluis Jan 30 '18 at 13:04
  • ok thank u for you valuable time sir – priya_d Jan 30 '18 at 13:07

1 Answers1

1

You shouldn't put a ListView inside a ScrollView because the ListView class implements its own scrolling and it just doesn't receive gestures because they all are handled by the parent ScrollView.

https://stackoverflow.com/a/6211286/

Even on the native platform development, it's discouraged as you can see on this question.

General Grievance
  • 4,555
  • 31
  • 31
  • 45
Diego Rafael Souza
  • 5,241
  • 3
  • 23
  • 62