If you go to Xamarin home page it will tell you that there are two types of Xamarin, native and forms. Native is for full pledge down to the metal apps for iOS and Android. Forms is for simpler enterprise apps which only need a simpler UI, forms share UI-code between all platforms even UWP, WPF etc. With embedded forms we now have a new way of doing Xamarin.
What is embedded Xamarin Forms?
With embedded Xamarin forms you don’t have to choose if your app should be native or forms at startup, instead you can choose for every view. It is now possible, with the latest update, to mix native and forms for every view, for example could the home view be native and simpler views such as about, details and other secondary views be forms and thus share all the code. And it is code sharing Xamarin is all about. To be able to have your app on multiple platforms with as much shared code as possible makes many things a lot easier and better.
How is this done?
In iOS you choose to navigate to a forms view instead of going to a iOS view. And android you simple create a fragment and swap out the content to the forms instead. Remember to install the Xamarin.Forms nuget into every head.
At first forms must be initialized.
This can be done when you need your first Xamarin forms view or do it in AppDelegate FinishedLaunching and it is done.
Add these lines wherever you want to show a forms view. May it be a button clicked or ItemSelected its depends on the app.
var page = new YourSharedForms();
var controller = page.CreateViewController();
In android you override OnCreate in your fragment and do more or less the same thing
protected override void OnCreate(Bundle bundle)
Forms.Init(this, null); // Only have to this once
var frag = new YourSharedForms().CreateFragment(this);
var ft = FragmentManager.BeginTransaction();
ft.Replace(Resource.Id.fragment_frame_layout, frag, "main");
I think Xamarin just got a lot more interesting. If you always have native capabilities and can use forms whenever you need, you got all the possibilities of native and all the shared code advantages of forms. And of course since forms are using a XAML base UI code it is a dream to work with considering the other options.
If you want to dig more into this please check out this link. Remember that it is no longer in beta so just use the latest version and you don’t need any preview NuGets.
As always please comment below if want to share anything.