转自:http://hi.baidu.com/willbelate/item/8296f40b15a7e3354bc4a35e

<Window x:Class="WPF中的三种透明方法.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
    <Grid>
        <Grid.Background>
            <ImageBrush
                ImageSource="D:\c.png"
                Stretch="Fill"
                ViewportUnits="RelativeToBoundingBox"
                Viewport="0,0,0.1,0.1"
                TileMode="Tile"/>
        </Grid.Background>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Button Grid.Row="0" Content="Hello" Opacity="0.5"></Button>
        <Button Grid.Row="1" Content="Hello" Background="#90000000"></Button>
        <Button Grid.Row="2" Content="Hello">
            <Button.OpacityMask>
                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                    <GradientStop Color="Transparent" Offset="0.3"/>
                    <GradientStop Color="Blue" Offset="1"/>
                </LinearGradientBrush>
            </Button.OpacityMask>
        </Button>
    </Grid>
</Window>
xmal设置

相关文章: