private async void OnCapturePhotoButtonClick(object sender, RoutedEventArgs e)
        {
            var file = await TestedControl.CapturePhotoToStorageFileAsync(ApplicationData.Current.TemporaryFolder);

            var bi = new BitmapImage();

            IRandomAccessStreamWithContentType stream;

            try
            {
                stream = await TryCatchRetry.RunWithDelayAsync <Exception, IRandomAccessStreamWithContentType>(
                    file.OpenReadAsync(),
                    TimeSpan.FromSeconds(0.5),
                    10,
                    true);
            }
            catch (Exception ex)
            {
                // Seems like a bug with WinRT not closing the file sometimes that writes the photo to.
                new MessageDialog(ex.Message, "Error").ShowAsync();

                return;
            }

            bi.SetSource(stream);
            PhotoImage.Source = bi;
            CapturedVideoElement.Visibility = Visibility.Collapsed;
            PhotoImage.Visibility           = Visibility.Visible;
        }
        private async void OnCaptureVideoButtonClick(object sender, RoutedEventArgs e)
        {
            if (!_capturingVideo)
            {
                CaptureVideoButton.Content = "Stop";
                _capturingVideo            = true;
                _videoFile = await TestedControl.StartVideoCaptureAsync(ApplicationData.Current.TemporaryFolder);

                CapturedVideoElement.Visibility = Visibility.Visible;
                PhotoImage.Visibility           = Visibility.Collapsed;

                IRandomAccessStreamWithContentType stream;

                try
                {
                    stream = await TryCatchRetry.RunWithDelayAsync <Exception, IRandomAccessStreamWithContentType>(
                        _videoFile.OpenReadAsync(),
                        TimeSpan.FromSeconds(0.5),
                        10);
                }
                catch (Exception ex)
                {
#pragma warning disable 4014
                    // Seems like a bug with WinRT not closing the file sometimes that it writes the video to.
                    new MessageDialog(ex.Message, "Error").ShowAsync();
#pragma warning restore 4014

                    return;
                }

                if (this.CapturedVideoElement == null)
                {
                    return;
                }

                this.CapturedVideoElement.SetSource(stream, _videoFile.ContentType);
            }
            else
            {
                CaptureVideoButton.Content = "Record";
                _capturingVideo            = false;

                await TestedControl.StopCapture();
            }
        }