void UpdateButtonOrientation()
        {
            // Rotate the UI app bar button to match the rotation of the device
            var angle     = CameraRotationHelper.ConvertSimpleOrientationToClockwiseDegrees(_rotationHelper.GetUIOrientation());
            var transform = new RotateTransform {
                Angle = angle
            };

            _takePhotoButton.RenderTransform = transform;
        }
        async Task SetPreviewRotationAsync()
        {
            // Only update the orientation if the camera is mounted on the device
            if (_externalCamera)
            {
                return;
            }

            // Add rotation metadata to the preview stream to ensure aspect ratio/dimensions match when rendering and getting preview frames
            var orientation = _rotationHelper.GetCameraPreviewOrientation();
            var properties  = _mediaCapture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview);

            properties.Properties.Add(RotationKey, CameraRotationHelper.ConvertSimpleOrientationToClockwiseDegrees(orientation));
            await _mediaCapture.SetEncodingPropertiesAsync(MediaStreamType.VideoPreview, properties, null);
        }