I thought I'd post some tips from my Windows Phone 7 book, and what better way to start than by answering some questions my new boss posted on Twitter!
Most of the time, you should try to not care which theme is in use by sticking with the various brushes/colors defined as application resources, such as PhoneForegroundBrush and PhoneBackgroundBrush. Sometimes you can't avoid it, though, and you want to write code such as this:
if (/* dark theme */) // Do dark theme stuffelse // Do light theme stuff
To accomplish this, you can leverage one of several pre-defined application resources:
Therefore, here are four different yet equivalent ways to express the preceding pseudo-code:
I used this technique in Tip Calculator to define my own theme-specific brushes for the bottom buttons that match the built-in Calculator app's buttons:
This was necessary because, alas, the necessary brushes are not already defined as application resources.