UWP Shadow 阴影
参考文字: https://mtaulty.com/2016/08/10/windows-10-uwp-and-composition-light-and-shade/
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid HorizontalAlignment="Center" VerticalAlignment="Center"> <Grid x:Name="grid" /> <TextBlock x:Name="txtBlock" Text="Drop Shadow" FontSize="48" HorizontalAlignment="Center" VerticalAlignment="Center" /> </Grid> </Grid>
var compositor = ElementCompositionPreview.GetElementVisual(this.grid).Compositor; var spriteVisual = compositor.CreateSpriteVisual(); spriteVisual.Size = this.grid.RenderSize.ToVector2(); var dropShadow = compositor.CreateDropShadow(); dropShadow.Mask = this.txtBlock.GetAlphaMask(); dropShadow.Offset = new Vector3(10, 10, 0); spriteVisual.Shadow = dropShadow; ElementCompositionPreview.SetElementChildVisual(this.grid, spriteVisual);
fffffffffffffffff
test red font.