开发者

I get following error: '#FF000000' is not a valid value for Color

开发者 https://www.devze.com 2023-02-19 12:41 出处:网络
I sometime get following error message: Cannot convert the value in attribute \'Color\' to object of type

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开发者_JAVA百科

The WPF code for HighlightTextBrush is:

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


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}" />
0

精彩评论

暂无评论...
验证码 换一张
取 消