private void Uninitialize()
        {


            if (_mediaElement != null)
            {
                _mediaElement.Source = null;
                _mediaElement = null;
            }

            if (_cameraStreamSource != null)
            {

                _cameraStreamSource = null;
            }



            if (_photoCaptureDevice != null)
            {
                _photoCaptureDevice.Dispose();
                _photoCaptureDevice = null;
            }
        }
        private async Task Initialize()
        {


            var resolution = PhotoCaptureDevice.GetAvailableCaptureResolutions(_cameraLocation).First();

            _photoCaptureDevice = await PhotoCaptureDevice.OpenAsync(_cameraLocation, resolution);

            Windows.Foundation.Size PreviewResolution;
            foreach (var res in PhotoCaptureDevice.GetAvailablePreviewResolutions(_cameraLocation).ToArray().Reverse())
            {
                try
                {
                    await _photoCaptureDevice.SetPreviewResolutionAsync(res);
                    PreviewResolution = res;
                    break;

                }
                catch (Exception e)
                {
                }
            }



            _cameraStreamSource = new CameraStreamSource(_photoCaptureDevice, PreviewResolution);

            _mediaElement = new MediaElement();
            _mediaElement.BufferingTime = new TimeSpan(0);
            _mediaElement.SetSource(_cameraStreamSource);

            // Using VideoBrush in XAML instead of MediaElement, because otherwise
            // CameraStreamSource.CloseMedia() does not seem to be called by the framework:/

            BackgroundVideoBrush.SetSource(_mediaElement);



            AdjustOrientation();
        }