1 设置效果为

2 窗体中代码为

<Window x:Class="QyNodeTest.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">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Style/Style.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>
    <Grid Style="{StaticResource bc}">
        <Border  Background="{StaticResource OpacityBrush}" Margin="0 180 0 0" VerticalAlignment="Center" Padding="10">
            <Image Source="/Img/19.jpg" Width="46" Height="46"   Clip="{StaticResource ResourceKey=clipGeometry}"></Image>
        </Border>   
    </Grid>
</Window>

3 样式文件style.xaml中代码为

  <Style TargetType="Grid" x:Key="bc">
        <Setter Property="Background">
            <Setter.Value>
                <ImageBrush ImageSource="/Img/loginBg.png"/>
            </Setter.Value>
        </Setter>
    </Style>
  
    <GeometryGroup x:Key="clipGeometry" FillRule="Nonzero">
        <EllipseGeometry RadiusX="23" RadiusY="23" Center="23, 23"></EllipseGeometry>
    </GeometryGroup>
    <SolidColorBrush Color="#2c2f3e" Opacity="0.8" x:Key="OpacityBrush"/>

 

posted on 2015-08-20 13:39  碎儿  阅读(3542)  评论(0编辑  收藏  举报