Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make a ContentPage with a StackLayout inside scrollable?

Here is the code I have:

<ContentPage>
   <ContentPage.Content>
       <StackLayout Spacing="10" Margin="20">
       <Label /> 
       <Label />
       <Label />
       .....
       <Label />
       <Label />
       </StackLayout>
   </ContentPage.Content>
</ContentPage>

There are a large number of labels, so many that they go off the end of the screen. But the screen won't scroll. How can I make it scrollable?

like image 929
Samantha J T Star Avatar asked Aug 25 '17 09:08

Samantha J T Star


2 Answers

<ContentPage.Content>
    <ScrollView>
        <StackLayout>
            <Label /> 
            <Label /> 
            <Label /> 
            <Entry />
        </StackLayout>
    </ScrollView>
</ContentPage.Content>
like image 149
ColeX - MSFT Avatar answered Oct 21 '22 12:10

ColeX - MSFT


If you only have Labels and they are pretty simple, why not use a ListView which has implicit scrolling? Otherwise Cole Xia is correct, wrap in a ScrollView

like image 23
Joagwa Avatar answered Oct 21 '22 13:10

Joagwa