Thursday 15 July 2010

wpf - Using a StaticResource SolidColorBrush to define the Gradient Stop Colors -


I am creating some wpf resource dictionaries with all the styles for an application! I have some LinearGradientBrush es, where the color is directly set as L inearGradientBrush in the context of GradientStop s However, I have a predefined color To which I can use the AA reference for each GradientStop , so changing the color scheme for the application is the case of changing values ​​of SolidColorBrush es: < / P>

  & lt; Solid color brush color = "# 5A5A5A" x: key = "colorbrush mammium" /> & Lt; Solid color brush color = "# 222222" x: key = "colorbrush dark" /> & Lt; LinearGradientBrush & gt; & Lt; GradientStop color = "{static resource colorbrushes median}" /> & Lt; GradientStop color = "{StaticResource colorbrushDark}" offset = "1" /> & Lt; / LinearGradientBrush & gt;  

With the above code example, I get the following error:

The value in the attribute can not be changed in the 'color' type of object For 'System Windows.Media.Color' '# 5A5A5A' property is not a valid value for 'color'

This line refers to the line where & lt; GradientStop color = "{StaticResource colorbrushMedium}" /> is defined.

Any thoughts?

OK, I got the problem:

Color and not SolidColorBrush .. < / P>

  & lt; Color x: key = "colorbrush mammium" & gt; # FF5A5A5A & lt; / Color & gt; & Lt; Color x: key = "colorbrush dark" & gt; # Ff 222222 & lt; / Color & gt; & Lt; LinearGradientBrush & gt; & Lt; GradientStop color = "{static resource colorbrushes median}" /> & Lt; GradientStop color = "{StaticResource colorbrushDark}" offset = "1" /> & Lt; / LinearGradientBrush & gt;  

It seems to solve my problem!


No comments:

Post a Comment