private async void btnStartStopPhotoSequence_Click(Object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            try
            {
                if (btnStartStopPhotoSequence.Content.ToString() == "Prepare PhotoSequence")
                {
                    if (!m_capture.VideoDeviceController.LowLagPhotoSequence.Supported)
                    {
                        rootPage.NotifyUser("Photo-sequence is not supported", NotifyType.ErrorMessage);
                    }
                    else
                    {
                        if (m_capture.VideoDeviceController.LowLagPhotoSequence.MaxPastPhotos < m_pastFrame)
                        {
                            m_pastFrame = m_capture.VideoDeviceController.LowLagPhotoSequence.MaxPastPhotos;
                            rootPage.NotifyUser("pastFrame number is past limit, reset passFrame number", NotifyType.ErrorMessage);
                        }

                        btnStartStopPhotoSequence.IsEnabled = false;

                        m_capture.VideoDeviceController.LowLagPhotoSequence.ThumbnailEnabled     = true;
                        m_capture.VideoDeviceController.LowLagPhotoSequence.DesiredThumbnailSize = 300;

                        m_capture.VideoDeviceController.LowLagPhotoSequence.PhotosPerSecondLimit = 4;
                        m_capture.VideoDeviceController.LowLagPhotoSequence.PastPhotoLimit       = m_pastFrame;

                        LowLagPhotoSequenceCapture photoCapture = await m_capture.PrepareLowLagPhotoSequenceCaptureAsync(ImageEncodingProperties.CreateJpeg());

                        photoCapture.PhotoCaptured += new Windows.Foundation.TypedEventHandler <LowLagPhotoSequenceCapture, PhotoCapturedEventArgs>(this.photoCapturedEventHandler);

                        m_photoSequenceCapture = photoCapture;

                        btnStartStopPhotoSequence.Content   = "Take PhotoSequence";
                        btnStartStopPhotoSequence.IsEnabled = true;
                        m_bPhotoSequence = true;
                    }
                }
                else if (btnStartStopPhotoSequence.Content.ToString() == "Take PhotoSequence")
                {
                    btnSaveToFile.IsEnabled = false;
                    m_frameNum      = 0;
                    m_ThumbnailNum  = 0;
                    m_selectedIndex = -1;
                    m_highLighted   = false;
                    Clear();

                    btnStartStopPhotoSequence.IsEnabled = false;
                    await m_photoSequenceCapture.StartAsync();
                }
                else
                {
                    rootPage.NotifyUser("Bad photo-sequence state", NotifyType.ErrorMessage);
                }
            }
            catch (Exception exception)
            {
                ShowExceptionMessage(exception);
            }
        }
        private async void InitializeMediaCapture()
        {
            _capturedSequence = new List<IRandomAccessStream>();

            _mediaCapture = new MediaCapture();

            var devices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
            var backCamera = devices.FirstOrDefault(x => x.EnclosureLocation != null && x.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Back);

            await _mediaCapture.InitializeAsync(new MediaCaptureInitializationSettings
            {
                StreamingCaptureMode = StreamingCaptureMode.Video,
                PhotoCaptureSource = PhotoCaptureSource.Auto,
                AudioDeviceId = string.Empty,
                VideoDeviceId = backCamera.Id
            });

            captureElement.Source = _mediaCapture;
            await _mediaCapture.StartPreviewAsync();

            var format = ImageEncodingProperties.CreateJpeg();
            format.Width = 640;
            format.Height = 480;

            _lowLagPhotoSequenceCapture = await _mediaCapture.PrepareLowLagPhotoSequenceCaptureAsync(format);            
            _lowLagPhotoSequenceCapture.PhotoCaptured += OnPhotoCaptured;
        }