Im trying to use ThemeManager in my WP 8 to change some default styling. I have one resource file which contains my color etc customizations.
My ThemeResources.xml
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:System="clr-namespace:System;assembly=mscorlib">
<Color x:Key="TestColor">#FF2c5f8c</Color>
<SolidColorBrush x:Key="TestBrush" Color="{StaticResource TestColor}"/>
</ResourceDictionary>
Now in my App.xml im setting this as merged dictionary:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Themes/ThemeResources.xaml"/>
</ResourceDictionary.MergedDictionaries>
<local:LocalizedStrings xmlns:local="clr-namespace:MyApp" x:Key="LocalizedStrings"/>
</ResourceDictionary>
</Application.Resources>
And in my App.cs, in my app constructor I use themeManager:
public App()
{
// Global handler for uncaught exceptions.
UnhandledException += Application_UnhandledException;
// Standard XAML initialization
InitializeComponent();
// Phone-specific initialization
InitializePhoneApplication();
// Language display initialization
InitializeLanguage();
// Get the custom theme
var rd = App.Current.Resources.MergedDictionaries[0];
// Set custom Theme, fallback to dark
ThemeManager.SetCustomTheme(rd, Theme.Light);
...
Finally, in my MainPage.xml I use this TestBrush, defined in ThemeResources.xml like this:
<TextBlock Text="Testing" Foreground="{StaticResource TestBrush}"/>
Everything looks correct to me, but when I try to run the app I get the following exception:
$exception {System.Windows.Markup.XamlParseException: Cannot find a Resource with the Name/Key TestBrush [Line: 90 Position: 175]
In Visual Studio designer it displays the color correcty.
What could be the issue there?
Edit:
And yes, ThemeResources.xml file's build action is set to "Resource". Still the same issue.