Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does brush have only 3 hexa value?

Tags:

.net

wpf

xaml

brush

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?

like image 657
Louis Rhys Avatar asked Sep 27 '11 11:09

Louis Rhys


2 Answers

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" />
like image 78
BoltClock Avatar answered Nov 13 '22 14:11

BoltClock


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

like image 4
Julian Avatar answered Nov 13 '22 15:11

Julian