I have a page in a Windows Phone 8.1 app where I have a few components that should be able to have three different color states. They should either be red, blue or the current theme's foreground color.
Therefore, if my app is started using the Dark theme on the phone, and then the user steps out of the app and changes the Light theme, and steps in to my app again, I need to immediately change components that had the old theme's foreground color.
Since the components are supposed to change between different colors (where the theme's foreground color is just one of them) I can't set their Foreground to PhoneForegroundColor in XAML.
What I've done is to add a Resuming event listener that does this:
myTextBlock.Foreground = new SolidColorBrush((Color)Application.Current.Resources["PhoneForegroundColor"]);
But... the Resuming event is fired before the resources of Application.Current are updated, so I end up with the same color as before. If the user steps out again and in again, it'll work since Application.Current.Resources["PhoneForegroundColor"] was updated at some point after the Resuming event the previous time.
Question: When can I first read the updated Application.Current.Resources["PhoneForegroundColor"], since Resuming doesn't seem to be the right place?
Question: Alternatively, is there a way for myTextBlock to inherit another component's ForegroundColor (CSS-ish), so that I can change the myTextBlock.Foreground programatically between Red/Blue/Inherit without having to mind changes to the Phone Theme within my app's lifecycle?
Any suggestions appreciated!