zoukankan      html  css  js  c++  java
  • WPF 实现阴影效果

    一、WPF最常见的一个阴影效果的类是DropShadowEffect。它有几种比较有用的属性比如:
    Color设置颜色
    Direction设置投影的方向
    ShadowDepth设置投影距纹理下方的距离
    Opacity设置透明度等等。

    角度的设置是这样的:

    下面是一个例子和效果:

    <TextBlock Text="HELLO WORLD" Foreground="Green" HorizontalAlignment="Center" Margin="20" FontSize="36">
        <TextBlock.Effect>
            <DropShadowEffect Color="Black" Direction="0" ShadowDepth="5" Opacity="1" />
        </TextBlock.Effect>
    </TextBlock>
    

     
    二、模糊效果的类BlurEffect。可以设置Radius模糊效果曲线的半径,KernelType计算模糊的曲线的值等等。

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

     
    三、用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>
    

     

  • 相关阅读:
    LINQ 查询介绍
    HTML DOM all 集合
    JavaScript eval() 函数
    软件设计之 数据库设计
    Asp.Net下导出/导入规则的Excel(.xls)文档
    软件设计之 用户界面设计
    HTML DOM focus() 方法
    HTML DOM blur() 方法
    HTML DOM Event 对象
    控件用法参考:GridView的用法大全
  • 原文地址:https://www.cnblogs.com/sntetwt/p/9686156.html
Copyright © 2011-2022 走看看