private void InsertShade(int insertIndex, Shade shade)
        {
            shade.PropertyChanged -= ShadePropertyChanged;
            InternalLogger.Debug(LogTag, () => $"InsertShade( insertIndex: {insertIndex}, shade: {shade} )");

            // https://docs.microsoft.com/en-US/windows/uwp/composition/using-the-visual-layer-with-xaml

            var ttv = _shadowSource.TransformToVisual(_shadowsCanvas);

            Windows.Foundation.Point offset = ttv.TransformPoint(new Windows.Foundation.Point(0, 0));

            double width  = _shadowSource.ActualWidth;
            double height = _shadowSource.ActualHeight;

            var shadowHost = new Rectangle()
            {
                Fill    = Xamarin.Forms.Color.White.ToBrush(),
                Width   = width,
                Height  = height,
                RadiusX = _cornerRadius,
                RadiusY = _cornerRadius,
            };

            Canvas.SetLeft(shadowHost, offset.X);
            Canvas.SetTop(shadowHost, offset.Y);

            _shadowsCanvas.Children.Insert(insertIndex, shadowHost);

            if (_compositor == null)
            {
                Visual hostVisual = ElementCompositionPreview.GetElementVisual(_shadowsCanvas);
                _compositor = hostVisual.Compositor;
            }

            var dropShadow = _compositor.CreateDropShadow();

            dropShadow.BlurRadius = (float)shade.BlurRadius * 2;
            dropShadow.Opacity    = (float)shade.Opacity;
            dropShadow.Color      = shade.Color.ToWindowsColor();
            dropShadow.Offset     = new Vector3((float)shade.Offset.X - SafeMargin, (float)shade.Offset.Y - SafeMargin, 0);
            dropShadow.Mask       = shadowHost.GetAlphaMask();

            var shadowVisual = _compositor.CreateSpriteVisual();

            shadowVisual.Size   = new Vector2((float)width, (float)height);
            shadowVisual.Shadow = dropShadow;

            _shadowVisuals.Insert(insertIndex, shadowVisual);

            ElementCompositionPreview.SetElementChildVisual(shadowHost, shadowVisual);
            shade.PropertyChanged += ShadePropertyChanged;
        }
        private void UpdateShadow(PancakeView pancake)
        {
            //For now gets the shadow only when the CornerRadius has the same value for all sides.
            if (Control != null && pancake.Shadow != null && pancake.Width > 0 && pancake.Height > 0 &&
                pancake.CornerRadius.TopLeft == pancake.CornerRadius.BottomRight &&
                pancake.CornerRadius.TopLeft == pancake.CornerRadius.BottomLeft &&
                pancake.CornerRadius.BottomRight == pancake.CornerRadius.TopRight)
            {
                rectangle.Fill    = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Black);
                rectangle.Width   = pancake.Width;
                rectangle.Height  = pancake.Height;
                rectangle.RadiusX = pancake.CornerRadius.TopRight + 5;
                rectangle.RadiusY = pancake.CornerRadius.TopRight + 5;

                var compositor = ElementCompositionPreview.GetElementVisual(rectangle).Compositor;
                visual      = compositor.CreateSpriteVisual();
                visual.Size = new Vector2((float)pancake.Width, (float)pancake.Height);

                var shadow = compositor.CreateDropShadow();
                shadow.BlurRadius = pancake.Shadow.BlurRadius;
                shadow.Mask       = rectangle.GetAlphaMask();
                shadow.Opacity    = pancake.Shadow.Opacity;
                shadow.Color      = pancake.Shadow.Color.ToWindowsColor();
                shadow.Offset     = new Vector3((float)pancake.Shadow.Offset.X, (float)pancake.Shadow.Offset.Y, 0);
                visual.Shadow     = shadow;

                ElementCompositionPreview.SetElementChildVisual(rectangle, visual);
            }
            else
            {
                if (rectangle != null)
                {
                    rectangle.Fill = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Transparent);
                }

                if (visual != null)
                {
                    visual.Shadow = null;
                    ElementCompositionPreview.SetElementChildVisual(rectangle, null);
                }
            }
        }