Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

Gray is darker than a DarkFray RSS

1 reply

Last post Aug 28, 2007 05:46 PM by Jonathan [MSFT]

(0)
  • VladF

    VladF

    Member

    216 Points

    87 Posts

    Gray is darker than a DarkFray

    Aug 28, 2007 05:16 PM | LINK

    Is it just me seeing this?

    Sample code:

    <Canvas x:Name="parentCanvas"

    xmlns="http://schemas.microsoft.com/client/2007"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Loaded="Page_Loaded"

    x:Class="SilverlightProject16.Page;assembly=ClientBin/SilverlightProject16.dll"

    Width="640"

    Height="480"

    Background="White"

    >

    <
    Rectangle Canvas.Top="0" Width="300" Height="100" Fill="LightGray"/>

    <TextBlock Canvas.Top="30" FontSize="32" Text="LightGray"/>

    <Rectangle Canvas.Top="100" Width="300" Height="100" Fill="Gray"/>

    <TextBlock Canvas.Top="130" FontSize="32" Text="Gray"/>

    <Rectangle Canvas.Top="200" Width="300" Height="100" Fill="DarkGray"/>

    <TextBlock Canvas.Top="230" FontSize="32" Text="DarkGray"/>

    </Canvas>

    Resulting image:

  • Jonathan [MSFT]

    Jonathan [MSFT]

    Member

    255 Points

    85 Posts

    Microsoft

    Re: Gray is darker than a DarkFray

    Aug 28, 2007 05:46 PM | LINK

    Believe it or not, VladF, it's working as intended.  See http://blogs.msdn.com/tims/archive/2006/06/02/614616.aspx for a full description.

    Here's an excerpt:

    The final way to express a colour in XAML is to use named colours, for instance Green, SteelBlue or MediumVioletRed. These colours are the same named colours as are present in HTML or SVG and include a number of quirks and idiosyncrasies that stem from their heritage. For example, the set of named colours isn't evenly spread across the spectrum (there are many red and orange hues against a comparative lack of shades green), and some of the colours have pretty esoteric names that display a lack of cultural awareness by the original author (how many non-US readers can fathom a guess at the colour DodgerBlue represents?). Some are even spelled inconsistently (for example, Gray and DarkGray have the US spelling, whereas LightGrey has the UK spelling).

    There's an even stranger phenomenon, however. These colours don't actually originate in HTML - they date still further back than that to the X Window System that originated on UNIX systems. The HTML specification defines sixteen named colours that map onto the basic sixteen colours present in the EGA palette, but the earliest browsers such as Mosaic also supported any of the other X11 named colours, based on their colour representation as defined on X. Unfortunately, some of the original sixteen named colours have different representations to the X11 equivalents, for example Green is represented in X11 in this colour, whereas in HTML it's represented in this colour. The unfortunate result is that Gray is defined as #808080 in HTML, but DarkGray is represented as #A9A9A9, meaning that they're the wrong way around. Since WPF allows the same named colours as HTML for compatibility, the result is that the same idiosyncrasies carry forward.