For a WP7 App I want to use an additional color to contrast whatever the the current theme color is.
I decided to make the contrast color ‘Red’ unless the theme color was already ‘Red’ in which case I would male the contract Color ‘ Blue’
But the following code does not work as it does not detect the theme color as ‘Red’ even though it has been set that way and is certainly showing that way in the app.
private void AssessContrastColor()
{
System.Diagnostics.Debug.WriteLine("In assess color");
SolidColorBrush themeBrush = App.Current.Resources["PhoneAccentBrush"] as SolidColorBrush;
Color themeColor = themeBrush.Color;
SolidColorBrush contrastBrush = new SolidColorBrush();
// contrastBrush.Color = ControlPaint.Light(themeColor);
if (themeColor == Colors.Red)
{
contrastBrush.Color = Colors.Blue;
}
else contrastBrush.Color = Colors.Red;
_ContrastThemeBrush = contrastBrush;
}
The code seems pretty straightforward, but, when looking at this through debugger, the Phone accent color when I get it (when its Red) is not #FFFF0000 but something a little different.
Just as an aside to this, was looking to create the contrast color as one that was a bit lighter than the theme color, looked around and it seemed like it could be quote a bit of code, but then stumbled across the ‘ControlPaint.Light call’ which seemed ideal, but doesnt seem to be an option uder WP7? Hence commented out above.
Any advice appreciated. Thanks
This would be because the Accent colour isn’t
Red, but something close to it, to be precise#E51400You can find a list of all the colours and how to use them here. And for future proofing the answer, a list of all the colours:
But I would strongly recommend against changing the contrast colours. You’re likely to make content less readable.