I’m working with WP7, and i’d like to create a custom brush (as a local resource) that uses different colors for dark and light themes (for instace, red if the theme is black and blue if it’s white).
How do i do it?
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The integrated/system brushes do not change their properties based on the theme, a different set of brushes is included based on the current theme. You can see the various versions of this in
%programfiles%\Microsoft SDKs\Windows Phone\v7.1\DesignI wrote a custom
ResourceDictionarythat implements theme support in the exact same way: by loading the appropriate theme dictionary depending on the light/dark theme.Here is a sample that uses it. It works in the Visual Studio designer as well as Blend, but doesn’t support white theme preview in Blend because Blend loads resources in a way that cannot be reproduced.
The above code loads in the resources from two different files, but they could just as easily be declared inline like any other ResourceDictionary.
The source for
ThemeResourceDictionaryis available on my original blog post, but it’s also on a different Stack Overflow question in case my blog ever implodes.