I Get Following Error: '#Ff000000' Is Not a Valid Value for Color

I sometime get following error message:

Cannot convert the value in attribute 'Color' to object of type 'System.Windows.Media.Color'. '#FF000000' is not a valid value for property 'Color'. Error at object 'HighlightTextBrush' in markup file

The WPF code for HighlightTextBrush is:

<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" 
  Color="{StaticResource {x:Static SystemColors.ControlTextBrushKey}}" />
1

2 Answers

You are trying to assign a Brush to the Color property. You need to use:

<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}"
    Color="{StaticResource {x:Static SystemColors.ControlTextColorKey}}" />

I had a problem using CodeNaked's answer where it returned the same error. I used this instead:

<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" 
Color="{Binding Source={x:Static SystemColors.ControlTextColorKey},Path=Color}" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest