I am trying to create an ResourceFile Called DataTemplate.xaml in an external dll and use that in a WP7 page. When I do the following in the header of my Page I get an erro
I tried the pack syntax while trying to share XAML ResourceDictionary files and got the same error message. I ended up using this syntax and it worked for me.
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/MyDLLName;component/Folder/MyXAMLFile.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Silverlight doesn't support pack URIs. It's a WPF feature.
If you examine the type of the Source
property for the Image
object in Silverlight it is Uri
. But in WPF the source is a dependency property with a type of ImageSource.
I've managed to get this to work using the following steps:
Added the following XAML to the new XAML file:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="ForegroundBrush" Color="Red" />
</ResourceDictionary>
In WP7ExternalResourcesTest, opened App.xaml and changed the Application.Resources
section to the following:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/WP7ExternalResourcesTestLibrary;component/External.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Foreground="{StaticResource ForegroundBrush}"
to the TextBlock
named "PageTitle".TextBlock
correctly displayed the words "page name" in red.Hope this helps.