开发者

Why does WPF use HTML/HEX Colors?

开发者 https://www.devze.com 2023-01-24 21:33 出处:网络
Why: <Trigger Property=\"ItemsControl.AlternationIndex\" Value=\"2\"> <Setter Property=\"Background\" Value=\"#FAC896\"></Setter>

Why:

<Trigger Property="ItemsControl.AlternationIndex" Value="2">
    <Setter Property="Background" Value="#FAC896"></Setter>
</Trigger>

and not:

<Trigger Property="ItemsControl.AlternationIndex" Value="2">
    <Setter Property="Background" Value="50 50 50 255"></Setter>
</Trigger>

?

Is this for performance reasons of the Xaml parser/compiler?

Reason I ask is, it's really difficult for artists to design an interface when they are used to RG开发者_Python百科B and/or HSV colors.

Btw I use VS 2010 WPF Editor.


If you're an artist, you should really be using Expression Blend. It will give you a very nice color picker, and it will handle the correct color codes for you. Also, the HEX number you provide is in the form of RGB. Two bytes of RED, two bytes of GREEN, and two bytes of BLUE.

To answer your question, someone from the WPF Design team would have to say, but I suspect it was used to keep some consistency with HTML.

As far as I know there is no difference between a HEX number, and a decimal number, they are all constants and have equal performance, since they are all represented as binary numbers in the computer.


I doubt it is for performance, it is probably just due to HTML conventions.

Anyway, if you are dealing with hex values you can mentally separate the components of the Hex color:

FA C8 96

And they "eyeball" them as values between 0 and 255 by knowing that there are 6 extra digits A (10), B (11), C (12), D (13), E (14), F (15).

Or just copy-and-paste the hex value into a 3rd party color picker...

0

精彩评论

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