Published April 06, 2017 by with 6 comments

StackLayout In Xamarin Forms

Stack Layout is used to arrange the view in one aspect . It could be vertical or horizontal . Stack Layout is the most simple layout control in xamarin forms.
We can also use nested Stack Layout depending on our requirements.
We can design beautiful Screens by using the Stack Layout. If you're familiar with the Microsoft XAML for UWP and WPF where we used the StackPanel then you could easily understand the Stack Layout as well.

Let's design a Login Screen by using Stack Layout and from that you'll get a clear point of how to use that control in xamarin forms.

So let's Add a few lines of XAML code in the Content Page. Let's create a beautiful Skype Login Page with the Stack Layout so let's switch to Visual Studio Or Xamarin Studio and add few lines of code there.


By default the orientation of StackLayout is Vertical but if you want the horizontal fashion of Stack Layout then you can easily do that by simply adding an Orientation = "Horizontal" in the Stack Layout .


<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:XF_Blogger"
             x:Class="XF_Blogger.MainPage" BackgroundColor="#00aff0">

  <StackLayout Margin="15,50,15,0">
    <Image Source="skype.png" VerticalOptions="Center" HorizontalOptions="Center"/>
    <StackLayout VerticalOptions="Center">
      <Entry BackgroundColor="White" Placeholder="Enter Skype ID" PlaceholderColor="Gray"/>
      <Entry BackgroundColor="White" Placeholder="Password" PlaceholderColor="Gray"/>
      <Button BackgroundColor="#078fc1" Text="Sign In"/>
      <Label Text="Problems signing in?" HorizontalTextAlignment="Center"></Label>
    </StackLayout>
  </StackLayout>
</ContentPage>

Now let's run this on the simulator or real device and just look at your UI for Login screen.



WOW ... Amazing it seems that we've almost design the same kinda Login Page in Xamarin Forms by just using the XAML.

6 comments:

  1. Woah!! Such a piece of the nice information you have shared here, I have read the entire post and I must say that the information is very helpful for me.
    Xamarin Development services in Indore

    ReplyDelete
  2. The article was absolutely fantastic! Lot of great information which can be helpful in some or the other way. Keep updating the blog, looking forward for more contents.
    by cloudi5 is the web development company in coimbatore

    ReplyDelete
  3. Thank you for taking the time to create such a detailed piece. Your blog is not only instructive, but also quite creative.

    web design development companies

    ReplyDelete

  4. Arena Infosolution is a leading Website development company in Jaipur , specializing in custom website development, e-commerce solutions, and web application development. They have a team of highly skilled developers who can create visually appealing and user-friendly websites.


    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete