[顶] Silverlight实现发光效果

    插播一篇与NParsing框架无关的文章。是我实际项目中积累一点小小经验,给大家分享一下。


    可能用过WPF的人知道,在WPF中实现发光效果很简单,用BitmapEffect就可以实现。但是Silverlight中没有BitmapEffect,在网上找了好几天的资料

也没找到决解办法。最终只能放弃了这种效果,让我不爽了好久。

    后然当我看到用BlurEffect对Rectangle做了模糊效果后,在脑袋里就有了这样一个想法。只要用两个Rectangle,下面那Rectangle

用BlurEffect做模糊效果不就是我要的发光效果吗。

代码如下:

<UserControl
    
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:System
="clr-namespace:System;assembly=mscorlib"
    xmlns:d
="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable
="d" xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    x:Class
="BTES_SilverlightApplication.MainPage"
    Width
="400" Height="300">
    
<Grid x:Name="LayoutRoot" Background="White">
        
<Rectangle Fill="Black" Stroke="Black" Margin="80">
            
<Rectangle.Effect>
                
<BlurEffect Radius="15"/>
            
</Rectangle.Effect>
        
</Rectangle>
        
<Rectangle Fill="Black" Stroke="Black" Margin="80"/>
    
</Grid>
</UserControl>

效果图

原文地址:https://www.cnblogs.com/zhidian/p/1722486.html