原文来自icyfox_bupt的博客,转载请注明来自:
http://blog.csdn.net/icyfox_bupt/article/details/7560023
想做一个外发光按钮,网上找的所有教程使用的都是
<Button.BitmapEffect>这个标签
但是我把代码复制以后发现不可以使用,经过查找资料,发现这个标签在.NET 3.5的时候已经过时了,但是写上以后并不会报错,怪不得我使用.NET 4.0的时候没有任何反应。
那在.NET 3.5以上要做外发光应该怎么做呢? 经过查找外国网站,笔者发现了一个办法,与大家分享。
.NET 4.0中只能用EFFECT标签来使用。将其中的
DropShadowEffect
的 ShadowDepth 改为0即可
示例:
XAML代码:
<Window x:Class="测试外发光.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid Background="Black" Height="325" Width="503">
<Button Content="这是不发光的" Margin="152,59,268,219">
</Button>
<Button Content="这是发光的" Margin="152,123,268,156">
<Button.Effect>
<DropShadowEffect ShadowDepth="0"
Color="White"
Opacity="1"
BlurRadius="20"/>
</Button.Effect>
</Button>
</Grid>
</Window>
.cs文件里没有代码啦,希望能给大家帮助。