This chapter is all about mix and match cross-platform UI and native platform UI. In the last recipe of the chapter, we will create a Xamarin.Forms solution and utilize the native APIs of each platform to capture a photo.
As usual, create a Xamarin.Forms project in Visual Studio using a PCL class library for our core shared project. Give it the name
XamFormsInAppPhoto
.Right-click our core PCL project and Add | Class…, name it
InAppCameraPage
, and click Add.Make it a
ContentPage
subclass.Go to the App.cs constructor and replace the code in the
MainPage
property assignment with a newInAppCameraPage
instance.MainPage = new InAppCameraPage();
That's all we need for our core project setup. We'll move now to the Android platform.
To get access in the related camera APIs of Android, we will need a custom
PageRenderer
for each platform. Right-click the Android project, Add | Class…, name the classInAppCameraPageRenderer
, and click Add...