wpf 添加阴影
//xaml里添加效果
<Image x:Name="jiantou" Source="pack://siteoforigin:,,,/Resources/工具栏/书本.png" Canvas.Left="485" Canvas.Top="868" Height="63" Width="65" Cursor="Hand" MouseLeftButtonDown="Image_MouseLeftButtonDown">
<Image.Effect>
<DropShadowEffect Color="Black" Direction="180" ShadowDepth="10" Opacity="0.4" />
</Image.Effect>
</Image>
//代码里添加
//阴影效果的设置
DropShadowEffect myDropShadowEffect = new DropShadowEffect();
Color myShadowColor = new Color();
myShadowColor.A = 255; // Note that the alpha value is ignored by Color property.
// The Opacity property is used to control the alpha.
myShadowColor.B = 50;
myShadowColor.G = 50;
myShadowColor.R = 50;
myDropShadowEffect.Color = myShadowColor;
// Set the direction of where the shadow is cast to 320 degrees.
myDropShadowEffect.Direction = 310;
// Set the depth of the shadow being cast.
myDropShadowEffect.ShadowDepth = 20;
// Set the shadow softness to the maximum (range of 0-1).
myDropShadowEffect.BlurRadius = 10;
// Set the shadow opacity to half opaque or in other words - half transparent.
// The range is 0-1.
myDropShadowEffect.Opacity = 0.4;
//添加阴影
Image image=new Image();
image.Effect = myDropShadowEffect;