tags:

views:

613

answers:

1

I am creating some wpf resourceDictionaries whit all the styles for an application! I have a few LinearGradientBrush'es, where the color is set directly in the LinearGradientBrush reference as GradientStop's. However, I want to have a predefined set of colors that I can use a a reference for each GradientStop, so that changing the color scheme for the application is a matter of changing the values of the SolidColorBrush'es:

<SolidColorBrush Color="#5A5A5A" x:Key="colorbrushMedium" /> 
<SolidColorBrush Color="#222222" x:Key="colorbrushDark" />  


<LinearGradientBrush>
    <GradientStop Color="{StaticResource colorbrushMedium}"/>
    <GradientStop Color="{StaticResource colorbrushDark}" Offset="1"/>
</LinearGradientBrush>

With the code example above, I am getting the following error:

Cannot convert the value in attribute 'Color' to object of type 'System.Windows.Media.Color'. '#5A5A5A' is not a valid value for property 'Color'.

The line it refers to is the line where < GradientStop Color="{StaticResource colorbrushMedium}" /> is defined.

Any ideas?

+4  A: 

Ok, I found the problem:

Using Color and not SolidColorBrush..

<Color x:Key="colorbrushMedium">#FF5A5A5A</Color>
<Color x:Key="colorbrushDark">#FF222222</Color>
<LinearGradientBrush>
    <GradientStop Color="{StaticResource colorbrushMedium}"/>
    <GradientStop Color="{StaticResource colorbrushDark}" Offset="1"/>
</LinearGradientBrush>

This seems to solve my problem!

code-zoop