Instantiating Xamarin Forms within an app
We instantiate Xamarin Forms within each supported platform of the app. Xamarin Forms support the following platforms:
Android
iOS
Windows Phone
Android
Typically, an activity to start an activity class looks like this:
public class MyActivity : Activity { protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // then whatever you need to do
To start a Xamarin Forms app, this changes as we are not inheriting the Activity
but a FormsApplicationActivity
, or more precisely:
public class MyActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity { protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); LoadApplication(new App()); } }
iOS
As with Android, we inherit FormsApplicationDelegate
in AppDelegate
instead of the usual UIApplicationDelegate
:
[Register("AppDelegate")] public partial class AppDelegate...