Volunteer .NET Evangelist

A well oiled machine can’t run efficiently, if you grease it with water.
posts - 44, comments - 88, trackbacks - 2, articles - 0
  首页  :: 联系 :: 订阅 订阅  :: 管理

Drop Shadow Effect In WPF

Posted on 2006-02-23 00:32  Sheva  阅读(...)  评论(...编辑  收藏
    In WPF, it ships with three built-in BitmapEffect classes, namely DropShadowBitmapEffect, OuterGlowBitmapEffect and BlurBitmapEffect, you can think of those bitmap effects as those available in IE CSS, actually both of them do exactly the same thing, i.e add flashy look and feel to your UI display, here is some xaml code demonstrating how to use those BitmapEffects in WPF application:
<Border xmlns="http://schemas.microsoft.com/winfx/avalon/2005" 
           xmlns:x
="http://schemas.microsoft.com/winfx/xaml/2005" 
           CornerRadius
="30" Height="200" Width="800" Margin="20" 
           BorderThickness
="4" BorderBrush="Red" Background="Green">
<StackPanel>
   
<StackPanel.Resources>
        <BitmapEffectGroup x:Key="effects">
    
       <DropShadowBitmapEffect Color="White" ShadowDepth="10" Softness="10"/>
            <BlurBitmapEffect Radius="6" KernelType="Box"/>
        </BitmapEffectGroup>
        <OuterGlowBitmapEffect x:Key="outerglow"/>
   
</StackPanel.Resources>
 
  <Label Margin="5,20,5,5" Content="Andriy Shevchenko" FontSize="80"  
           FontFamily
="Segoe UI" FontWeight="Bold" BitmapEffect="{StaticResource effects}" />
   <Label FontSize="20" Margin="240,0,5,5" FontFamily="Segoe UI" 
          Content
="The Number One Striker In The World" BitmapEffect="{StaticResource outerglow}"/>
</StackPanel>
</Border>
 
    And here is the screenshot of this
little nice logo:



    As an off topic, Sheva a.k.a Andriy Shevchenko is my idol:-)