Skip to main content

Replacing SystemColors with Hex value

If you're in a similar situation as me, using SystemColors is not an option, and you would rather use the real hex values. The following is a chart of all of the colors and their respective hex value:

         
                #FFB4B4B4  :  ActiveBorderColor
                #FF99B4D1  :  ActiveCaptionColor
                #FF000000  :  ActiveCaptionTextColor
                #FFABABAB  :  AppWorkspaceColor
                #FFF0F0F0  :  ControlColor
                #FFA0A0A0  :  ControlDarkColor
                #FF696969  :  ControlDarkDarkColor
                #FFE3E3E3  :  ControlLightColor
                #FFFFFFFF  :  ControlLightLightColor
                #FF000000  :  ControlTextColor
                #FF000000  :  DesktopColor
                #FFB9D1EA  :  GradientActiveCaptionColor
                #FFD7E4F2  :  GradientInactiveCaptionColor
                #FF6D6D6D  :  GrayTextColor
                #FF3399FF  :  HighlightColor
                #FFFFFFFF  :  HighlightTextColor
                #FF0066CC  :  HotTrackColor
                #FFF4F7FC  :  InactiveBorderColor
                #FFBFCDDB  :  InactiveCaptionColor
                #FF000000  :  InactiveCaptionTextColor
                #FFFFFFE1  :  InfoColor
                #FF000000  :  InfoTextColor
                #FFF0F0F0  :  MenuColor
                #FFF0F0F0  :  MenuBarColor
                #FF3399FF  :  MenuHighlightColor
                #FF000000  :  MenuTextColor
                #FFC8C8C8  :  ScrollBarColor
                #FFFFFFFF  :  WindowColor
                #FF646464  :  WindowFrameColor
                #FF000000  :  WindowTextColor
                #FFB4B4B4  :  ActiveBorderBrush
                #FF99B4D1  :  ActiveCaptionBrush
                #FF000000  :  ActiveCaptionTextBrush
                #FFABABAB  :  AppWorkspaceBrush
                #FFF0F0F0  :  ControlBrush
                #FFA0A0A0  :  ControlDarkBrush
                #FF696969  :  ControlDarkDarkBrush
                #FFE3E3E3  :  ControlLightBrush
                #FFFFFFFF  :  ControlLightLightBrush
                #FF000000  :  ControlTextBrush
                #FF000000  :  DesktopBrush
                #FFB9D1EA  :  GradientActiveCaptionBrush
                #FFD7E4F2  :  GradientInactiveCaptionBrush
                #FF6D6D6D  :  GrayTextBrush
                #FF3399FF  :  HighlightBrush
                #FFFFFFFF  :  HighlightTextBrush
                #FF0066CC  :  HotTrackBrush
                #FFF4F7FC  :  InactiveBorderBrush
                #FFBFCDDB  :  InactiveCaptionBrush
                #FF000000  :  InactiveCaptionTextBrush
                #FFFFFFE1  :  InfoBrush
                #FF000000  :  InfoTextBrush
                #FFF0F0F0  :  MenuBrush
                #FFF0F0F0  :  MenuBarBrush
                #FF3399FF  :  MenuHighlightBrush
                #FF000000  :  MenuTextBrush
                #FFC8C8C8  :  ScrollBarBrush
                #FFFFFFFF  :  WindowBrush
                #FF646464  :  WindowFrameBrush
                #FF000000  :  WindowTextBrush
                #FFF0F0F0  :  InactiveSelectionHighlightBrush
                #FF000000  :  InactiveSelectionHighlightTextBrush
     

The following code will generate that list if you would like to see it for yourself.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
    foreach (PropertyInfo i in typeof(SystemColors).GetProperties())
    {
        string colorName = i.Name;
        if (i.PropertyType == typeof(Color))
        {
            Color colorHex = (Color)i.GetValue(new Color(), BindingFlags.GetProperty, null, null, null);
            textBox.Text += colorHex.ToString() + "\t : \t" + colorName + Environment.NewLine;
        }
        else if(i.PropertyType == typeof(SolidColorBrush))
        {
            Color colorHex = ((System.Windows.Media.SolidColorBrush)(i.GetValue(new SolidColorBrush(), BindingFlags.GetProperty, null, null, null))).Color;
        textBox.Text += colorHex.ToString() + "\t : \t" + colorName + Environment.NewLine;
        }
    }


Finally, replacing it is quite simple:

BorderBrush="{x:Static SystemColors.ControlDarkBrush}" -> BorderBrush="#FFA0A0A0"

Comments

Post a Comment

Popular posts from this blog

Connecting VS 2008 to TFS?

Trouble connecting vs 2008 to TFS? If you are running a newer version of TFS, 2008 does not understand collections. In order to fix that, you need the following installed: SP1 http://www.microsoft.com/en-us/download/details.aspx?id=13276 Team Explorer http://www.microsoft.com/en-us/download/details.aspx?id=16338 Forwards Compatibility https://www.microsoft.com/en-us/download/details.aspx?id=10834

File menu opening on wrong side? [Windows 10]

If you are using windows 10 and the file menu opens on the left side, here is a fix: Run (Win+R) paste the following: shell:::{80F3F1D5-FECA-45F3-BC32-752C152E456E} click "Other" tab choose "Left-handed" Now the menu should open within the window:

Visual Studio stuck during install?

Let me start by saying this is a weird one. If you are installing VS and you notice that progress bar just isn't moving. Chances are it is stuck on something internally, to kick it out of this state, we "threaten" visual studio by initiating a windows shut down. This will result in windows prompting you to make sure you want to follow through. You can cancel out of the shutdown, and it should release visual studio from the stuck progress bar or what ever perpetual task it was stuck on.