我正在尝试使用Win2D软件包在UWP应用中创建投影。这是文档(https://docs.microsoft.com/en-us/windows/uwp/composition/using-the-visual-layer-with-xaml)的逐行显示。为什么阴影看起来像这样而不是光滑:
Xaml:
<Grid >
<Border x:Name="ShadowHost" />
<Border Width="562" Height="250" Background="White" />
</Grid>
C#:
private void OnLoaded(object sender, RoutedEventArgs e)
{
Compositor shadowCompositor;
Visual hostVisual;
hostVisual = ElementCompositionPreview.GetElementVisual(this.ShadowHost);
shadowCompositor = hostVisual.Compositor;
var dropShadow = shadowCompositor.CreateDropShadow();
dropShadow.Offset = new Vector3(0, 16, 0);
dropShadow.BlurRadius = 80.0f;
dropShadow.Color = Color.FromArgb(128, 0, 0, 0);
var spriteVisual = shadowCompositor.CreateSpriteVisual();
spriteVisual.Size = new Vector2(562f, 250f);
spriteVisual.Shadow = dropShadow;
ElementCompositionPreview.SetElementChildVisual(this.ShadowHost, spriteVisual);
var bindSizeAnimation = shadowCompositor.CreateExpressionAnimation("hostVisual.Size");
bindSizeAnimation.SetReferenceParameter("hostVisual", hostVisual);
spriteVisual.StartAnimation("Size", bindSizeAnimation);
}