With
the Xamarin.Forms API, a solitary UI can take a shot at three distinct
platforms: iOS, Android, and Windows Phone - tremendous investment funds in
code composing! Wei-Meng Lee gives cases for working Find xamarin Developers Xamarin.Forms,
demonstrating the sorts of the route your interfaces can use on the individual
platforms.
While
Xamarin is a blessing from heaven for developers wanting to fabricate
cross-platform applications for the iOS, Android, and Windows Phone platforms,
keeping up various UI code is as yet an agony for general developers. In spite
of the fact that a huge piece of the application rationale can be composed once
and reused for various platforms, developers still have needed to code
independently for iOS, Android, and Windows Phone.
Not
any longer. In May 2014 Xamarin presented the Xamarin.Forms API, which enables
developers to manufacture shared screens for iOS, Android, and Windows Phone.
Utilizing the Xamarin.Forms API, you can make a solitary code base for your UI,
and Xamarin will consequently make an interpretation of it into the local UI
components for every platform that you're focusing on.
In
this article, I'll enable you to begin with Xamarin.Forms by making distinctive
pages utilizing the different classes accessible in the API.
Making
The Project
Dispatch
Xamarin Studio and make another arrangement. Select Mobile Apps and after that
Blank App (Xamarin.Forms.Portable), and name the undertaking HelloWorld (see
Figure 1).
Figure
1
Figure
1 Creating An Undertaking That Uses The Xamarin.Forms Api.
At
the point when the undertaking is made, see that it contains three separate
tasks, as portrayed in the accompanying table and appeared in Figure 2.
Name
Portrayal
HelloWorld
This
task contains all the cross-platform shared code and shared UI libraries.
HelloWorld.Android
This
task contains an Android application.
HelloWorld.iOS
This
task contains an iOS application.
Figure
2
Figure
2 The Different Undertakings In A Xamarin.Forms Arrangement.
Look
at the substance of the App.cs record situated in the HelloWorld venture:
utilizing
System;
utilizing
Xamarin.Forms;
namespace
HelloWorld
{
open
class App
{
open
static Page GetMainPage ()
{
return
new ContentPage {
Content
= new Label {
Content
= "Hi, Forms!",
VerticalOptions
= LayoutOptions.CenterAndExpand,
HorizontalOptions
= LayoutOptions.CenterAndExpand,
},
};
}
}
}
The
App class contains a static technique named GetMainPage() that profits an
occasion of the Page class. A Page class in Xamarin.Forms fill in as a holder
for showing things inside a window (screen). A ContentPage is a solitary unit
of the show (consider it a View Controller in iOS and an Activity in Android).
In this illustration, the substance of the page (as spoke to utilizing the
Content property) just contains one Label control, which shows the subtitle
"Hi, Forms!".
How
About We Analyze The Mainactivity.Cs Document In The Helloworld.Android
Venture:
utilizing
System;
utilizing
Android.App;
utilizing
Android.Content;
utilizing
Android.Content.PM;
utilizing
Android.Runtime;
utilizing
Android.Views;
utilizing
Android.Widget;
utilizing
Android.OS;
utilizing
Xamarin.Forms.Platform.Android;
namespace
HelloWorld.Android
{
[Activity
(Label = "HelloWorld.Android.Android",
MainLauncher
= genuine,
ConfigurationChanges
= ConfigChanges.ScreenSize |
ConfigChanges.Orientation)]
open
class MainActivity : AndroidActivity
{
ensured
abrogate void OnCreate (Bundle package)
{
base.OnCreate
(package);
Xamarin.Forms.Forms.Init
(this, package);
SetPage
(App.GetMainPage ());
}
}
}
At
the point when the movement is stacked, it stacks its substance by calling the
GetMainPage() technique for the App class, which restores an occasion of the
ContentPage class.
Presently
How About We Look At The Appdelegate.Cs Document In The Helloworld.Ios Venture:
utilizing
System;
utilizing
System.Collections.Generic;
utilizing
System.Linq;
utilizing
MonoTouch.Foundation;
utilizing
MonoTouch.UIKit;
utilizing
Xamarin.Forms;
namespace
HelloWorld.iOS
{
[Register
("AppDelegate")]
open
halfway class AppDelegate : UIApplicationDelegate
{
UIWindow
window;
open
abrogate bool FinishedLaunching (
UIApplication
application, NSDictionary choices)
{
Forms.Init
();
window
= new UIWindow (UIScreen.MainScreen.Bounds);
window.RootViewController
=
App.GetMainPage
().CreateViewController ();
window.MakeKeyAndVisible
();
return
genuine;
}
}
}
Additionally,
for this situation, the AppDelegate class calls the GetMainPage() strategy for
the App class to get an occurrence of the ContentPage class. Utilizing the
ContentPage class, it calls the CreateViewController strategy to restore an Find
xamarin Developers occurrence of the UIViewController class with the goal that
it can be allocated to the RootViewController property of the window.