• 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这个里面包含了很多效果哦

  • 相关阅读:
    java继承中的初始化顺序
    java可访问修饰符
    java简单数据类型转化
    java运算符优先级
    面向切面编程的例子
    什么是面向切面编程
    return 的使用
    通过修改my.ini配置文件来解决MySQL 5.6 内存占用过高的问题
    spring 注入使用注解(不用xml)
    spring在扫描包中的注解类时出现Failed to read candidate component错误
  • 原文地址:https://www.cnblogs.com/shuoshuo/p/2087967.html
Copyright © 2020-2023  润新知