5

For example, in this page there is code such as:

<SolidColorBrush x:Key="DisabledBorderBrush" Color="#AAA" />

Why does the color property only have 3 hex value? Doesn't color normally have 6 or 8 hex value? (like Fill="#FF0000FF") What does the 3 hexes means? mean?

Louis Rhys
  • 34,517
  • 56
  • 153
  • 221

3 Answers3

8

Brush colors may be specified in hex notation with three, four, six or eight digits as shown in the MSDN page for SolidColorBrush:

<object property="#rgb"/>
- or -
<object property="#argb"/>
- or -
<object property="#rrggbb"/>
- or -
<object property="#aarrggbb"/>

#rgb expands to #rrggbb (like it does in CSS hex notation), and #argb expands to #aarrggbb. Using three or six digits, the alpha is always maxed out. That is, these are all equivalent:

<SolidColorBrush x:Key="DisabledBorderBrush" Color="#AAA" />
<SolidColorBrush x:Key="DisabledBorderBrush" Color="#FAAA" />
<SolidColorBrush x:Key="DisabledBorderBrush" Color="#AAAAAA" />
<SolidColorBrush x:Key="DisabledBorderBrush" Color="#FFAAAAAA" />
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
  • I haven't tried it, but you should be able to use all these notations with any other XAML attribute that takes a `Color`. – BoltClock Sep 27 '11 at 11:09
4

If you use a 3 digit value, each digit is automatically doubled, so #AAA is equivalent to #AAAAAA and #123 = #112233

Julian
  • 2,021
  • 16
  • 21
0

Your example FF0000FF represents 4 Hex (tuple) values which represent 4 Bytes (RGBA). The term #AAA is a shortvalue term. #AAA equals #AAAAAA equals #FFAAAA

jami
  • 190
  • 2
  • 14