protected override void Dispose(bool disposing) { if (disposing) { Control?.Preview?.Release(); cameraPreview = null; } base.Dispose(disposing); }
protected override void OnElementChanged(ElementChangedEventArgs <WasteApp.CameraPreview> e) { base.OnElementChanged(e); if (e.OldElement != null) { cameraPreview.Click -= OnCameraPreviewClicked; } if (e.NewElement != null) { if (Control == null) { cameraPreview = new CameraPreview(Context); SetNativeControl(cameraPreview); } e.NewElement.OpenCamera = () => { try { if (Control.Preview != null) { Control.Preview.Release(); Control.Preview = null; } Control.Preview = Camera.Open((int)e.NewElement.Camera); } catch { } //cameraPreview.Click -= OnCameraPreviewClicked; //cameraPreview.Click += OnCameraPreviewClicked; }; } }