Friday, October 26, 2012

Get Windows Phone Accent Color

Some times an application needs to know which accent color is currently in use on the device so it can adjust it's UI.

The PhoneAccentColor key indicates the accent color as a Color object.
The PhoneAccentBrush key indicates the accent color as a Brush object.

In XAML you can do something like:
<TextBlock Foreground="{StaticResource PhoneAccentBrush}" />
<Border>
  <Border.Background>
    <SolidColorBrush Color="{StaticResource PhoneAccentColor}" />
  </Border.Background>
</Border>
In C#:
Color AccentColor = (Color)Resources["PhoneAccentColor"];
Brush AccentBrush = (Brush)Resources["PhoneAccentBrush"];

No comments:

Post a Comment