WPF Behaviors之玻璃效果及其扩展

来源:转载

废话不多说,直接上代码上图

 

相关控件下载

XAML

<Window x:Class="GlassTest.Window2"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/expression/2009/interactivity"
xmlns:local="clr-namespace:GlassTest"
xmlns:ShaderEffectLibrary="clr-namespace:ShaderEffectLibrary;assembly=ShaderEffectLibrary"
Title="Window2" Height="300" Width="300">
<Grid>
<Grid x:Name="grid2">
<Grid x:Name="grid1">
<Grid x:Name="grid" HorizontalAlignment="Stretch" 

VerticalAlignment="Stretch" Width="Auto" Height="Auto">
<Image x:Name="image" Margin="0,0,0,0" 

Source="ws_Vista_Background_1600x1200.jpg" Stretch="Fill"/>
</Grid>
</Grid>
<Border Margin="133.667,35.333,28,51.334" Background="#FF545454" 

BorderBrush="#FF000000" BorderThickness="1,1,1,1" CornerRadius="8,8,8,8">
<i:Interaction.Behaviors>
<local:GlassBehavior Visual="{Binding ElementName=grid1, Mode=OneWay}">
<local:GlassBehavior.Effect>
<BlurEffect/>
</local:GlassBehavior.Effect>
</local:GlassBehavior>
</i:Interaction.Behaviors>
<Border.Effect>
<DropShadowEffect BlurRadius="20" ShadowDepth="1"/>
</Border.Effect>
<StackPanel>
</StackPanel>
</Border>
</Grid>
<Border Margin="32.001,8,129.666,112" Background="#FF545454" 

BorderBrush="#FF000000" BorderThickness="1,1,1,1" CornerRadius="8,8,8,8">
<i:Interaction.Behaviors>
<local:GlassBehavior Visual="{Binding ElementName=grid2, Mode=OneWay}">
<local:GlassBehavior.Effect>
<ShaderEffectLibrary:LightStreakEffect />
</local:GlassBehavior.Effect>
</local:GlassBehavior>
</i:Interaction.Behaviors>
<Border.Effect>
<DropShadowEffect BlurRadius="25" ShadowDepth="1"/>
</Border.Effect>
<StackPanel>
</StackPanel>
</Border>
</Grid>
</Window>

是不是很简单呢,ShaderEffectLibrary这个里面包含了很多效果哦

本文来自硕硕的博客,原文地址:http://www.cnblogs.com/shuoshuo/archive/2011/06/23/WPF_Behaviors.html


分享给朋友:
您可能感兴趣的文章:
随机阅读: