Resource dictionary [modified]
-
Hello! i have a problem with the resource dictionaries in silverlight, control styles is using the colors in my colors resource. but when i do this i get runtime error when i load the silverlight app in my browser: Cannot find a Resource with the Name/Key OfficeBlue [Line: 10 Position: 44] i have confirmed that the key name exists in colors.xaml this is from my app.xaml
<Application.Resources>
<ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Colors.xaml" /> <ResourceDictionary Source="Navigate/Control styles.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources>
How do i use colors.xaml resource in my control style? Thanks!
modified on Tuesday, April 19, 2011 2:25 AM
-
Hello! i have a problem with the resource dictionaries in silverlight, control styles is using the colors in my colors resource. but when i do this i get runtime error when i load the silverlight app in my browser: Cannot find a Resource with the Name/Key OfficeBlue [Line: 10 Position: 44] i have confirmed that the key name exists in colors.xaml this is from my app.xaml
<Application.Resources>
<ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Colors.xaml" /> <ResourceDictionary Source="Navigate/Control styles.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources>
How do i use colors.xaml resource in my control style? Thanks!
modified on Tuesday, April 19, 2011 2:25 AM
It is unable to find the Resource file. Give a proper path there. A typical resource dictionary path will look as below:
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/ASSEMBLY_NAME;component/FILENAME.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>Note: Change the name of the ASSEMBLY_NAME in the above code. Also change the FILENAME. If it is in a different sub directory, say "Themes", it will look as below:
<ResourceDictionary Source="/ASSEMBLY_NAME;component/Themes/FILENAME.xaml"/>
Hope this will answer your query. Mark as Answer, if this helps.
Regards - Kunal Chowdhury | Microsoft MVP (Silverlight) | CodeProject MVP | Software Engineer
New Articles on Silverlight 5 Beta: Debugging Data Bindings in XAML | Working with Multiple Click (ClickCount)
Appreciate your Vote and Feedback