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>
2
  • 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. Commented Jan 30, 2018 at 13:04
  • ok thank u for you valuable time sir Commented Jan 30, 2018 at 13:07

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.