private void SetupVisual() { var hostVisual = ElementCompositionPreview.GetElementVisual(element: ShadowHost); var compositor = hostVisual.Compositor; // Create a drop shadow DropShadow dropShadow = compositor.CreateDropShadow(); dropShadow.Color = Color.FromArgb(255, 22, 33, 44); dropShadow.BlurRadius = 15.0f; dropShadow.Offset = new Vector3(12.5f, 2.5f, 0.0f); // Associate the shape of the shadow with the shape of the target element dropShadow.Mask = CircleImage.GetAlphaMask(); // Create a Visual to hold the shadow SpriteVisual shadowVisual = compositor.CreateSpriteVisual(); shadowVisual.Shadow = dropShadow; // Add the shadow as a child of the host (Ellipse) in the visual tree ElementCompositionPreview.SetElementChildVisual(element: ShadowHost, visual: shadowVisual); // Ensure the size of shadow host and shadow visual always stay in sync ExpressionAnimation bindSizeAnimation = compositor.CreateExpressionAnimation(expression: "hostVisual.Size"); bindSizeAnimation.SetReferenceParameter(key: "hostVisual", compositionObject: hostVisual); shadowVisual.StartAnimation(propertyName: nameof(shadowVisual.Size), animation: bindSizeAnimation); }