I’m am adding the following code to the constructor of App.xaml.cs in my WP7 application.
Resources["PhoneBackgroundBrush"] = new ImageBrush
{
ImageSource = new BitmapImage(new Uri("/images/bg.png", UriKind.Relative))
};
after running it I get NotImplementedException once the applicaion is opened.
Any idea of how can we do this?
What I’m trying to achieve is a single theme application like Facebook that always have white theme regardless of phone’s theme.
As a note, getter on the resources always work, so it’s not that accessing phone resources is totally blocked from code. (I’m using this to determine current theme and accent of phone).
var a = Resources["PhoneBackgroundBrush"]; // this works fine
For simple examples it isn’t complicated when you know how, however you shouldn’t rename PhoneBackgroundBrush, but create a new key for your resources.
You need to create the resources in App.xaml (or you can pull in MergedDictionaries other places too, but that’s more advanced).
Test.jpgneeds to be a resource file in your project.In App.xaml:
In a page for example:
If you’re starting to re-template a control (say a Button), that when you need to crack open Blend and modify the default styles of controls. It’s pretty well documented, and builds on these same principles…