I am trying to create a metro app based on a Developing windows 8 book by Oreilly.
I have the following code, based on the blank metro template
Type rootType = typeof(DependencyObject);
TypeInfo rootTypeInfo = typeof(DependencyObject).GetTypeInfo();
List<Type> classes = new List<Type>();
Brush highlightBrush;
public MainPage()
{
this.InitializeComponent();
highlightBrush = this.Resources["ControlHighlightBrush"] as Brush;
the last line throws this exception. As far as I understand it will search in the common folder the ControlHighlightBrush but if its not present in StandardStyles.xaml file it wont work?
I think thats whats happenning?
An exception of type ‘System.Runtime.InteropServices.COMException’ occurred in mscorlib.dll but was not handled in user code
Additional information: Error HRESULT E_FAIL has been returned from a call to a COM component.
If there is a handler for this exception, the program may be safely continued.
I don’t think it looks in any common folder for resources by default. Resources have to be explicitly specified in the App.xaml in MergedDictionary collection:
So, you would add your custom styles in some file like CustomStyles.xaml and include it as above.