C# – First steps with C# and .NET – part 017 .

This tutorial shows you the base of any structure of the Xamarin project with a short intro into the Xamarin.Essentials install area.
Take a look at the next image:

First, if the new default project doesn’t have the Xamarin.Essential ( see point 4 on image) then you need to install it with the NuGet Packages tool.
You can use from main menu Tool or right-click on the solution name and select the Manage NuGet Packages for Solution… to add it.
I used the last stable version of Xamarin.Essentials.
This project solution comes with a default tree with items that let you build an Android application.
The first item (see point 1 on image) is that part of the project for the android area.
The android interface is created with a XAML file and is named MainPage.xaml (see point 2 on image), see source code:

The last part is the MainActivity.cs file (see point 3 on image) and that is used to create the base Android application, see source code:

These methods are based on the android activity lifecycle from the documentation webpage.
The Resources folder has images and files and some android permissions and indents are into the AndroidManifest.xml file and MainPage.xaml.cs file.
The next step is to create a C# class named MyStaticClass into the default project Xamarin_Essentials_001 and link it
In Xamarin.Forms, all views have the property named BindingContext this specifies the object that a view should data-bind with.
When coding with XAML, we can use the x:Static markup extension to reference a static C# property and explicitly provide an instance of a C# class as the binding context:

About the binding process you can read more information on the official webpage.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.