I am currently building a WP7 application using the MVVMLight framework. I would like to add a resource dictionary to my app.xaml, but when I do this, it will not work. Here is snipit from app.xaml
<Application.Resources> <vm:ViewModelLocator x:Key="Locator" d:IsDataSource="True" /> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="View/StyleResourceDictionary.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources>
Since I'm using ViewModelLocator, which has a key, I get an error message warning me that I cannot mix resources with keys without them. After adding the key to the resource dictionary, it looks like this:
<ResourceDictionary x:Key="resourceDictionary"> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="View/StyleResourceDictionary.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary>
In the resource dictionary, I have a style with the key "TitleTemplate". In any case, when I try to reference a resource dictionary from one of my views, it fails. Sample code from my view is given below:
<TextBlock Name="TB_ContactNameLabel" Text="contact" Style="{StaticResource TitleTemplate}"/>
The designer immediately gives me the error "Resource" TitleTemplate "cannot be resolved". If I refer to a resource dictionary key (i.e.: resourceDictionary), an error does not occur, but it does nothing. Finally, if I add resourceDictionary directly to the page in my resources, instead of app.xaml, everything will be fine. I do not want to add it to all the representations that I plan to use. Did I miss something?
source share