Ali Eren
Ali Eren

Reputation: 499

Xamarin Forms Listview in Scrollview doesn't scroll

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
         x:Class="Dh.ListPage">
<ContentPage.Content>
    <ScrollView>
        <StackLayout Style="{StaticResource MainStackLayoutWhenLoggedInStyle}">
            <Frame Style="{StaticResource FrameStyle2}">
                <StackLayout>
                    <Label Text="Vragenlijsten" Style="{StaticResource TitelLabelStyle}" />
                </StackLayout>
            </Frame>
            <Frame Style="{StaticResource FrameStyle2}">
                <StackLayout>
                    <Label Text="DRINGENDE VRAGEN: vul deze vragen meteen in!" Style="{StaticResource StandardLabelStyle}"/>
                    <Frame Style="{StaticResource FrameStyle2}">
                        <StackLayout Style="{StaticResource ListViewStackLayoutStyle}" >
                            <ListView ItemTapped="OnItemTapped" ItemsSource="{Binding Question_Lists}" Style="{StaticResource StandardListViewStyle}">
                                <ListView.ItemTemplate>
                                    <DataTemplate>
                                        <ViewCell>
                                            <ViewCell.View>
                                                <Label Text="{Binding Title}" Style="{StaticResource StandardLabelStyle}" />
                                            </ViewCell.View>
                                        </ViewCell>
                                    </DataTemplate>
                                </ListView.ItemTemplate>
                            </ListView>
                        </StackLayout>
                    </Frame>
                </StackLayout>
            </Frame>
        </StackLayout>
    </ScrollView>
</ContentPage.Content>

When my screen is too small then my listview does not want to scroll. If my screen is not too small then listview does scroll. Can someone help me pls?

Upvotes: 4

Views: 6967

Answers (3)

lsaudon
lsaudon

Reputation: 1468

Put your StackLayout in ListView.Header or ListView.Footer

<ListView ItemsSource="{Binding Comments}">
    <ListView.Header>
        <StackLayout Padding="30,30,30,0">
            <Label Text="Article" />
        </StackLayout>
    </ListView.Header>
    <ListView.Footer>
        <StackLayout HeightRequest="85" />
    </ListView.Footer>
</ListView>

Upvotes: 0

LCJ
LCJ

Reputation: 22661

Xamarin.Forms.ScrollView Class documentation says:

Application developers should not nest one ScrollView within another. Additionally, they should refrain from nesting them other elements that can scroll, such as WebView.

ListView.ScrollTo Method Scrolls the ListView to the item.

Upvotes: 1

Malte G
Malte G

Reputation: 792

Never stack a ListView inside a ScrollView as both implement scrolling on Android at least.

Upvotes: 6

Related Questions