How to use Label,Button and Image in Xamarin.Forms

Xamarin.Forms
img_xamarin

In our last tutorial we have seen how to create a Hello World app for basic understanding of XamarinForms.In this tutorial we are going to see some basic controls that we may need to create a functional app in real world.

After we complete our tutorial it will look like this:

xf2.1

Let’s Start:
Create a new Solution and go to C#-> Mobile Apps -> Blank App (Xamarin.Forms Portable) and give name “StdControlsXamarinForm”.

xf2.2

Go to StdControlsXamarinForm.cs file and you will see code for Label , delete that code because we don’t need it.
Now in Constructor of App create object of a Label, Button and Image:

Here, we created a Label, Image and Button control to display in our tutorial app. Now try to build and run the app.

We’ve added a button but when you click on it, it will not do anything, because we didn’t handle it’s click event of button.
For that add this code:

Now try to build and run the app, if you did everything right you will see your demo app like:

xf2.3

xf2.4

If you like this tutorial then you can download full copy of the code from github

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">