zoukankan      html  css  js  c++  java
  • 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这个里面包含了很多效果哦

  • 相关阅读:
    ckeditor详解
    c#实现生产者消费者模式
    逻辑思维题01
    关于nginx的安装
    一些关于python的小感想
    关于linux上pdf阅读器
    将python2.7+django1.10部署到SAE上
    配置github上的SSH key及上传自己的项目到github
    解决ubuntu15 下没有声音
    linux小倒腾
  • 原文地址:https://www.cnblogs.com/shuoshuo/p/2087967.html
Copyright © 2011-2022 走看看