2012-05-16 36 views
1

我有一些代碼將DropShadowBitmapEffect應用於UserControl。BitmapEffect替換效果

Visual Studio中說,this.BitmapEffect棄用,我們必須使用Effects

應該怎麼做呢?

DropShadowBitmapEffect myDropShadowEffect = new DropShadowBitmapEffect(); 
myDropShadowEffect.Color = GetShadowColorValue(); 
myDropShadowEffect.Direction = 250; 
// Set the depth of the shadow being cast. 
myDropShadowEffect.ShadowDepth = 0; 
// 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.7; 
// Apply the bitmap effect to the Button. 
this.BitmapEffect = myDropShadowEffect; // BitmapEffect is deprecated 

回答

2
DropShadowEffect myDropShadowEffect = new DropShadowEffect(); 

myDropShadowEffect.Color = GetShadowColorValue(); 
myDropShadowEffect.Direction = 250; 

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

// 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.7; 

// Apply the effect to the Button. 
this.Effect = myDropShadowEffect; 

我不知道是什麼的Softness相當於...你可以嘗試調整BlurRadius