Stack Layout In Xamarin

So, let’s get started. First, we’ll discuss the Xamarin Controls.

Open a new project and name it whatever you want. I named it as X_Controls. Let’s add a label in your xaml page.
xaml page
After this, let's start an android project. So, just right click on the Android Project and set as startup project, which will set your startup project.

Now, just run it on your emulator or a device and see your start screen saying,"Welcome to Xamarin Forms"
start screen
Now, we add more controls and again run it. It will override the previous control and hide that from our page.

code

start screen
In order to do so, we need a Container. A container is just like a shopping bag-  you can put anything inside it quite easily. So, let’s implement a Container in our application.

Two very common containers are Grid and StackLayout. We’ll discuss StackLayout.

Anything you put inside the StackLayout will go down and new Controls come on the top.

Let's try to add StackLayout and add these Controls into StackLayout.
code
Here we go....
output
Have you noticed these controls looking awesome in StackLayout? By default, the orientation property of StackLayout is vertical.
code
output
Now, what if you want to add these controls in horizontal fashion? Simple! Add orientation. This is equal to horizontal and all your controls inside the StackLayout will go into the horizontal fashion.
code
output

X

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now