在wpf中获取RadialGradientBrush的问题

时间:2012-10-12 13:08:04

标签: wpf styles radial-gradients

<Border CornerRadius="20" BorderThickness="1" HorizontalAlignment="Left" Height="36" Margin="168,88,0,0" VerticalAlignment="Top" Width="36" BorderBrush="#FFBDD8D7">
        <Border.Background>
            <RadialGradientBrush GradientOrigin="0.317,-0.336" RadiusY="0.746" RadiusX="0.667">
                <RadialGradientBrush.RelativeTransform>
                    <TransformGroup>
                        <ScaleTransform CenterY="0.5" CenterX="0.5" ScaleY="1" ScaleX="1"/>
                        <SkewTransform AngleY="0" AngleX="0" CenterY="0.5" CenterX="0.5"/>
                        <RotateTransform Angle="174.743" CenterY="0.5" CenterX="0.5"/>
                        <TranslateTransform/>
                    </TransformGroup>
                </RadialGradientBrush.RelativeTransform>
                <GradientStop Color="#FF0099FF" Offset="0.051"/>
                <GradientStop Color="#FF00090A" Offset="1"/>
                <GradientStop Color="#FF33CCFF" Offset="0.761"/>
                <GradientStop Color="#FF24BDFF" Offset="0.438"/>
            </RadialGradientBrush>
        </Border.Background>
    </Border>

结果将如下所示

enter image description here

但是我需要像下面那样的结果。我该怎么做呢?

enter image description here

1 个答案:

答案 0 :(得分:0)

尝试这样的事情:

<Window x:Class="WpfApplication16.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>
    <RadialGradientBrush x:Key="GlowFX" GradientOrigin="0.75,0.75" Center="0.5,0.5">

        <GradientStop Color="#0073c0" Offset="1"/>
        <GradientStop Color="#FF33CCFF" Offset="0.861"/>
        <GradientStop Color="#FF24BDFF" Offset="0.438"/>
    </RadialGradientBrush>
</Window.Resources>
<Grid>
    <Border CornerRadius="20" BorderThickness="1" HorizontalAlignment="Left" Height="36" Margin="168,88,0,0" VerticalAlignment="Top" Width="36" BorderBrush="#FFBDD8D7"
            Background="{StaticResource GlowFX}">
    </Border>
</Grid>