mHelpMe
mHelpMe

Reputation: 6668

WPF Style for rectangle - fill not working

I have a WPF application. I have a rectangle that I want to fill with a radial brush that I have created. However when I go to set the value of the fill property with the name of my radial brush it tell me token is not valid?

<RadialGradientBrush x:Key="brushRadSecurity" RadiusY="0.825" RadiusX="0.669">
        <RadialGradientBrush.RelativeTransform>
            <TransformGroup>
                <ScaleTransform CenterY="0.5" CenterX="0.5" ScaleY="1.248" ScaleX="1.276"/>
                <SkewTransform CenterY="0.5" CenterX="0.5"/>
                <RotateTransform CenterY="0.5" CenterX="0.5"/>
                <TranslateTransform Y="0.317" X="-0.007"/>
            </TransformGroup>
        </RadialGradientBrush.RelativeTransform>
        <GradientStop Color="#940FDCDC" Offset="0"/>
        <GradientStop Offset="1"/>
        <GradientStop Color="#94022FF3" Offset="0.974"/>
        <GradientStop Color="#940092C9" Offset="0.526"/>
        <GradientStop Color="#940FDCDC" Offset="0.25"/>
        <GradientStop Color="#940052C9" Offset="0.703"/>
    </RadialGradientBrush>


<Style x:Key="recSecurity" TargetType="Rectangle">
        <Setter Property="HorizontalAlignment" Value="Stretch"/>
        <Setter Property="VerticalAlignment" Value="Stretch"/>
        <Setter Property="Opacity" Value="0"/>
        <Setter Property="RadiusX" Value="10"/>
        <Setter Property="RadiusY" Value="10"/>
        <Setter Property="StrokeThickness" Value="0"/>
        <Setter Property="Fill" Value="brushRadSecurity"/>
    </Style>

Upvotes: 0

Views: 2990

Answers (2)

yo chauhan
yo chauhan

Reputation: 12295

try this

<Setter Property="Fill" Value="{StaticResource brushRadSecurity}"/>

Upvotes: 2

Clemens
Clemens

Reputation: 128013

It should read

<Setter Property="Fill" Value="{StaticResource brushRadSecurity}"/>

Upvotes: 2

Related Questions