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 ha开发者_如何学编程ve 6 or 8 hex value? (like Fill="#FF0000FF") What does the 3 hexes means? mean?
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" />
If you use a 3 digit value, each digit is automatically doubled, so #AAA
is equivalent to #AAAAAA
and #123
= #112233
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
精彩评论