Building the CameraViewRenderer in Android
Now we must add the CustomRenderer for the Android camera. In the Renderers
folder, add a new file called CameraViewRender.cs
and implement the following:
public class CameraViewRenderer : ViewRenderer<CameraView, CameraDroid> { #region Private Properties private CameraDroid Camera; #endregion }
Our renderer contains only one private instance of the CameraDroid
class. Then we override the OnElementChanged
method:
#region Protected Methods protected override void OnElementChanged(ElementChangedEventArgs<CameraView> e) { base.OnElementChanged(e); if (Control == null) { Camera = new CameraDroid(Context); SetNativeControl(Camera); } if (e.NewElement != null) { Camera.Available += e.NewElement.NotifyAvailability; Camera.Photo...