WPF阴影效果

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

下面是一个例子和效果:

[html]  view plain  copy
  1. <TextBlock Text="HELLO WORLD" Foreground="Green" HorizontalAlignment="Center" Margin="20" FontSize="36">  
  2.             <TextBlock.Effect>  
  3.                 <DropShadowEffect Color="Black" Direction="0" ShadowDepth="5" Opacity="1" />  
  4.             </TextBlock.Effect>  
  5.         </TextBlock>  


2.接下来是模糊效果的类BlurEffect。可以设置Radius模糊效果曲线的半径,KernelType计算模糊的曲线的值等等。

[html]  view plain  copy
  1. <TextBlock Text="Hello world" Foreground="Green" HorizontalAlignment="Center" Margin="20" FontSize="36">  
  2.             <TextBlock.Effect>  
  3.                 <BlurEffect Radius="4" KernelType="Box" />  
  4.             </TextBlock.Effect>  
  5.         </TextBlock>  

 

3.好吧貌似没撒能用的了,不过还可以用TranslateTransform来叠两个同样的东西来显示弄出阴影效果。

[html]  view plain  copy
  1. <Grid>  
  2.     <TextBlock Text="helloworld" Foreground="Black" HorizontalAlignment="Center" Margin="20" FontSize="36">  
  3.             <TextBlock.RenderTransform>  
  4.                 <TranslateTransform X="3" Y="3" />  
  5.             </TextBlock.RenderTransform>  
  6.     </TextBlock>  
  7.     <TextBlock Text="helloworld" Foreground="Green" HorizontalAlignment="Center" Margin="20" FontSize="36" />  
  8.   
  9. </Grid>  


4.最后弄张相框类型的阴影图片来玩玩。

[html]  view plain  copy
  1. <Border SnapsToDevicePixels="True" BorderBrush="Red" BorderThickness="4" CornerRadius="5" Margin="20" HorizontalAlignment="Center" VerticalAlignment="Center">  
  2.     <Image Width="200" Source="C:\Users\lenovo\Downloads\1.jpg" Stretch="Uniform" />  
  3.     <Border.Effect>  
  4.         <DropShadowEffect Color="Black" BlurRadius="16" ShadowDepth="0" Opacity="1" />  
  5.     </Border.Effect>  
  6. </Border>  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值