WPFの阴影效果

UI实现过程中有的需要实现投影效果,那么怎么实现呢?整理了几种方式,供参考和查阅

1、图片做成阴影效果的,这个不多说了,和美工小姐姐多共同就好了

2、控件的DropShadowEffect属性

        <StackPanel Background="#FFFFFF" Width="941" Height="585">
            <StackPanel.Effect>
                <DropShadowEffect Color="#3699dd" Opacity="0.33" ShadowDepth="4" 
                                  Direction="180" BlurRadius="40" RenderingBias="Performance" />
            </StackPanel.Effect>
        </StackPanel>

上面的几个子属性名字很简单易懂

3、模糊效果类BlurEffect

<TextBlock Text="Hello world" Foreground="red" HorizontalAlignment="Center" Margin="20" FontSize="36">
            <TextBlock.Effect>
                <BlurEffect Radius="4" KernelType="Box" />
            </TextBlock.Effect>
</TextBlock>

4、TranslateTransform来叠两个同样的东西(当然可以颜色不一样)来显示弄出阴影效果

<Grid>
<TextBlock Text="helloworld" Foreground="Black" HorizontalAlignment="Center" Margin="20" FontSize="36">
<TextBlock.RenderTransform>
<TranslateTransform X="3" Y="3" />
</TextBlock.RenderTransform>
</TextBlock>
<TextBlock Text="helloworld" Foreground="Green" HorizontalAlignment="Center" Margin="20" FontSize="36" />

</Grid>

 如有疑问,请加群568055323联系群主。

posted @ 2018-07-05 15:19  卖雨伞的小男孩  阅读(252)  评论(0编辑  收藏  举报