Home > Desktop > WPF HighContrast (High contrast support with Windows Presentation Foundation)

WPF HighContrast (High contrast support with Windows Presentation Foundation)

I hate the literature, but I know that’s necessary for a blog.

Lets go to the practice !!!

Many applications have enhanced UI (User Interface) but doesn’t support all high contrast color schemes.

Two examples:

Example 1. Microsoft Office 2007 applications in High Contrast #2 color scheme:

office2k7 in High Contrast click image to enlarge

Example 2. Windows live applications in all high contrast color schemes:

Windows Live Apps in High Contrast

Demo:

You can create similar UIs with WPF (Windows Presentation Foundation) while fully supporting high contrast color schemes. The approach that I used isn’t, maybe, the best practical one but can be used as starting point to solve this problem.

The sample application support all system’s default high contrast color schemes (black, white, #1 and #2) and can be easily extended.

WPF Sample App in High Contrast WPF Sample App in Normal Contrast

Code: (Main function)

public static bool IsHighContrast()
{
    bool isHighContrast = false;

    if (SystemColors.ControlColor.ToString() == "#FF000000")
    {
        if (SystemColors.ControlTextColor.ToString() == "#FFFFFFFF"
            || SystemColors.ControlTextColor.ToString() == "#FF00FF00")  // High Contrast #1, #2 and Black.
        {
            isHighContrast = true;
        }
    }
    else if (SystemColors.ControlColor.ToString() == "#FFFFFFFF")
    {
        if (SystemColors.ControlTextColor.ToString() == "#FF000000") // High Contrast White.
        {
            isHighContrast = true;
        }
    }

    return isHighContrast;
}

Download source code (zip): WPF HighContrast.zip

Advertisements
Categories: Desktop Tags: , , ,
  1. Andrew
    January 25, 2011 at 1:53 pm

    Do you know what might be even easier?

    oControl.Background = SystemColors.WindowBrush

    That way, you are actively respecting the background color.

  2. January 30, 2011 at 11:18 am

    Andrew :

    Do you know what might be even easier?

    oControl.Background = SystemColors.WindowBrush

    That way, you are actively respecting the background color.

    Hi Andrew,
    what if you need a custom brush for the background?

  3. April 12, 2013 at 12:57 am

    To jest właściwie zaszczytny i pomocny kawałek informacji.
    Jestem rada , że trafiłam na Twój blog. Dzięki
    za udostępnienie.

  4. April 27, 2013 at 7:39 am

    Yes! Finally something about website.

  5. May 9, 2013 at 2:56 am

    Hello mates, how is everything, and what you would like to say about this article, in
    my view its in fact amazing in support of me.

  6. July 8, 2013 at 9:56 pm

    For example, the peak incidence of tonsil stone treatment in Early Pregnancy Primary
    tonsil stone treatment infection in the period from January to July this
    year, the officials said on Friday. Four of the six
    children who died had pre-existing medical conditions, including asthma and eczema, your pediatrician may
    recommend using an antiviral drug. My first son Mikail
    was infected with the tonsil stone treatment in just 3 days or less.

  7. Ute
    August 18, 2013 at 3:37 am

    Hi there, its nice piece of writing concerning media print, we all know media is a fantastic source of information.

  8. June 9, 2014 at 6:07 pm

    Wow that was unusual. I just wrote an extremely long comment but after I
    clicked submit my comment didn’t appear. Grrrr… well I’m not writing all
    that over again. Anyways, just wanted to say superb blog!

  9. June 10, 2014 at 2:35 am

    I just could not depart your website before suggesting that I actually loved the
    standard info a person supply in your guests?
    Is gonna be bacdk steadily in order to inspect new posts

  10. Johna772
    August 15, 2014 at 10:36 am

    I simply couldn’t depart your site prior to suggesting that I actually loved the standard info an individual supply for your guests? Is going to be back regularly in order to inspect new posts. edfbeekgeeae

  11. September 22, 2014 at 1:11 am

    I think it is great idea for everyone. I like this posts. Thanks.

  12. October 5, 2014 at 10:26 am

    Excellent post. I was checking constantly this weblog and
    I’m inspired! Very useful information specially
    the last phase 🙂 I care for such information a lot.
    I used to be seeking this particular info for a long time.
    Thank you and best of luck.

  13. October 25, 2014 at 11:34 am

    Very great post. I just stumbled upon your weblog and wanted to
    mention that I have really loved surfing around your blog posts.

    After all I’ll be subscribing for your rss feed and I’m
    hoping you write again soon!

  14. June 30, 2015 at 11:46 pm

    Excellent pieces. Keep posting such kind of info on your
    site. Im really impressd by it.
    Hi there, You have performed a great job. I will definitely digg it andd personally recommend to my friends.
    I’m sure they will be benefited from this website.

  15. raedbenz
    September 25, 2015 at 5:03 pm

    Hello,

    Has any managed to download the source code (zip)?

    Thanks

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s