The following forum(s) are migrating to a new home on Microsoft Q&A (Preview): Developing Universal Windows apps!

Ask new questions on Microsoft Q&A (Preview).
Interact with existing posts until December 13, 2019, after which content will be closed to all new and existing posts.

Learn More

How to use theme colors RRS feed

  • Question

  • I want to make button with color theme background.

    For example if my theme is yellow I want background will be yellow.

    For example if my theme is orange I want background will be orange.

    Q1. How to do that

    Q2. What is the common way to work with theme resources in WP. I meang theme background, theme foregorund?

    I am newbie. I tried to search, but couldn't find good example

    My .NET Blog with projects and feedback.

    Since May 30, 2014 I am waiting for Microsoft fix these 2 bug. If you know how to speed them up, please help

    Thursday, January 22, 2015 9:45 AM


  • Hi, try either method.

    In XAML:

    <Button Background="{ThemeResource PhoneBackgroundBrush}" x:Name="btn1">
        Some button

    In C#:

    btn1.Background = (SolidColorBrush)Application.Current.Resources["PhoneBackgroundBrush"];

    As to your second question: generally it is a good idea to conform to whatever theme the user has chosen. So if the user's theme's Accent color is red, you don't make a button that flashes blue when the user taps on it. You can do that by using Theme colors as much as possible instead of defining and using your custom made colors. The accent brush is called PhoneAccentBrush. Here's a link with the theme names and descriptions:

    • Edited by Aria2014 Thursday, January 22, 2015 10:23 AM
    • Marked as answer by SmartWhy Thursday, January 22, 2015 1:34 PM
    Thursday, January 22, 2015 10:17 AM