Why does applying this gradient style break my silverlight app ?

Posted by Robotsushi on Stack Overflow See other posts from Stack Overflow or by Robotsushi
Published on 2011-01-08T21:48:17Z Indexed on 2011/01/08 21:54 UTC
Read the original article Hit count: 142

Filed under:

I am having some issues with applying a gradient to a RadButton.

I have a gradient definition in my styles resource dictionairy like so :

 <LinearGradientBrush x:Key="GridView_HeaderBackground" EndPoint="0.5,1" StartPoint="0.5,0">
    <GradientStop Color="#FF5B5B5B" Offset="1"/>
    <GradientStop Color="#FF868686"/>
    <GradientStop Color="#FF4F4F4F" Offset="0.42"/>
    <GradientStop Color="#FF0E0E0E" Offset="0.43"/>
</LinearGradientBrush>

When i apply this gradient directly to the background of a RadButton everything works. Here is the button and the template definition:

Button

<telerik:RadButton Margin="5,10,5,0"  Click="RadButton_Click" Tag="30" Content="30 Days" Style="{StaticResource SliderButton}" Background="{StaticResource GridView_HeaderBackground}"  />

Template:

 <!-- Style Template for Slider RadButton -->
<Style x:Key="SliderButton" TargetType="telerik:RadButton">

    <Setter Property="Height" Value="30" />
    <Setter Property="Foreground" Value="#FFFFFF" />
    <Setter Property="BorderThickness" Value="0" />
    <Setter Property="Margin" Value="5,2" />
</Style>

However when applying this gradient in the resource dictionary, my application will not load it simply gets to the silverlight loading screen and then never proceeds

Here is the button and template which breaks my app.

Button:

<telerik:RadButton Margin="5,10,5,0"  Click="RadButton_Click" Tag="30" Content="30 Days" Style="{StaticResource SliderButton}" />

Template:

 <!-- Style Template for Slider RadButton -->
    <Style x:Key="SliderButton" TargetType="telerik:RadButton">
        <Setter Property="Background" Value="{StaticResource GridView_HeaderBackground}" />
        <Setter Property="Height" Value="30" />
        <Setter Property="Foreground" Value="#FFFFFF" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Margin" Value="5,2" />
    </Style>

When i observe the js error console in google chrome i notice the following error is produced:

"Cannot find a resource with the name/key ResourceWrapper"

© Stack Overflow or respective owner

Related posts about Silverlight