c# – WPF:从代码隐藏中为一个元素添加一个dropshadow效果

我以为这会很简单,但到目前为止我没有发现任何事情.你怎么做呢?

解决方法

只是试试这个
// Get a reference to the Button.
Button myButton = new Button();

// Initialize a new DropShadowBitmapEffect that will be applied
// to the Button.
DropShadowBitmapEffect myDropShadowEffect  = new DropShadowBitmapEffect();
// Set the color of the shadow to Black.
Color myShadowColor = new Color();
myShadowColor.ScA = 1;
myShadowColor.ScB  = 0;
myShadowColor.ScG  = 0;
myShadowColor.ScR  = 0;
myDropShadowEffect.Color = myShadowColor;

// Set the direction of where the shadow is cast to 320 degrees.
myDropShadowEffect.Direction = 320; 

// Set the depth of the shadow being cast.
myDropShadowEffect.ShadowDepth = 25; 

// Set the shadow softness to the maximum (range of 0-1).
myDropShadowEffect.softness = 1;
// Set the shadow opacity to half opaque or in other words - half transparent.
// The range is 0-1.
myDropShadowEffect.Opacity = 0.5; 

// Apply the bitmap effect to the Button.
myButton.BitmapEffect = myDropShadowEffect;

相关文章

在要实现单例模式的类当中添加如下代码:实例化的时候:frmC...
1、如果制作圆角窗体,窗体先继承DOTNETBAR的:public parti...
根据网上资料,自己很粗略的实现了一个winform搜索提示,但是...
近期在做DSOFramer这个控件,打算自己弄一个自定义控件来封装...
今天玩了一把WMI,查询了一下电脑的硬件信息,感觉很多代码都...
最近在研究WinWordControl这个控件,因为上级要求在系统里,...