How to make a StackLayout Scrollable?

Posted by seven.srikanth@gmail.com at 01-12-2017 18:26:10 in Article



You can make your view scrollable by using Scrollview.
Sample code below.
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"              xmlns:local="clr-namespace:WaterBookingApp"              x:Class="WaterBookingApp.Views.Main">
    <ContentPage.ToolbarItems >         <ToolbarItem Name="MenuItem1" Order="Primary" Icon="Microsoft.png" Text="Login" Priority="0" />     </ContentPage.ToolbarItems>     <ScrollView>      <StackLayout>         <StackLayout>             <StackLayout VerticalOptions="FillAndExpand">                 <Label Text="Welcome to Company!" FontSize="Large" VerticalOptions="CenterAndExpand" HorizontalOptions="CenterAndExpand" Margin="0,60,0,0"/>                 <Image x:Name="LoginIcon" Source="LoginLogo.png" Margin="0,80,0,0" />             </StackLayout>             <StackLayout>
                <StackLayout.Padding>                     <OnIdiom x:TypeArguments="Thickness">                         <OnIdiom.Phone>40,0,40,0</OnIdiom.Phone>                         <OnIdiom.Tablet>140,150,140,0</OnIdiom.Tablet>                     </OnIdiom>
                </StackLayout.Padding>                 <BoxView HeightRequest="1" Margin="0,10,0,10"  WidthRequest="1" Color="White" />                 <Label Text="Book Now" />                 <BoxView HeightRequest="1" Margin="0,10,0,10"  WidthRequest="1" Color="White" />                 <Label x:Name="LbNavigationBarl_NumberofCans" Text="Number of Cans" />                 <Picker x:Name="numberpicker" Title="Number of Cans" />
                <Label x:Name="Lbl_Address" Text="Delivery Address" />                 <Entry x:Name="Entry_Address" Text="Your Address here" />                 <Button x:Name="Btn_Book" Text="Proceed" Clicked="Btn_Book_Clicked" />             </StackLayout>         </StackLayout>     </StackLayout>     </ScrollView> </ContentPage>

Tags: Scrollview; StackLayout Scrollable; Xamarin Forms



0 Comments
Login to comment.

Recent Comments

Be the first to Comment. You can ask a Query or Share your toughts or Just say thanks.