6

I'm using Expression Blend 3 and am writing some of the XAML by hand, specifically the color values of controls.

I have a list of RGB colors already converted to hexadecimal. I just need to insert the hex value into my XAML.

Initially, I pasted the hex value from an email into the appropriate properties. Before I could finish, Blend started having a fit, underlining the color property with a squiggle and a tooltip telling me "Token is not valid." After some research, I found placing a pound sign ("#") in front of the hex value resolved this issue.

In the process of researching this problem, I started changing colors via the color picker in Blend. I quickly found the values Blend was inserting not only started with the pound sign, but also "FF". The values I was pasting were valid colors in a valid hex format. But when entering the RGB values into Blend and letting Blend insert the hex value, I noticed all my colors were prefixed with "#FF". Removing the #, as I already pointed out, generated errors, but removing the "FF" seemed to have no effect at all.

In the world of hexadecimal colors, is the color #5A7F39 really the same as #FF5A7F39? Why the FF? They are two different hex values, right? But they appear identical onscreen. Why the difference?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
DenaliHardtail
  • 27,362
  • 56
  • 154
  • 233

3 Answers3

15

That may be the alpha component of the color, which represents the opacity (00 -> transparent, FF -> opaque).

MSDN seems to agree with this: Color

16-bit hexadecimal, alpha -- #AARRGGBB

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Pierre Bourdon
  • 10,521
  • 4
  • 33
  • 27
  • 1
    I'm a bit confused by how, according to the article, 1 hex digit represents 8 bits and 2 hex digits represents 16 bits. – snarf Sep 28 '09 at 00:19
2

I believe the leading FF is the alpha. 255 (or FF) being 100% opaque, and 00 would be transparent.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
John Christman
  • 583
  • 4
  • 11
0

The 'extra' FF is an alpha value (degree of transparency). If you only have three hexadecimal pairs, the alpha value is assumed to be ff (no transparency). However, if you compare #335A7F39 and #FF5A7F39, you should see a difference.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131