Windows phone 7 当我尝试加载一个充满数据模板的合并ResourceDictionary时,会出现一个XamlParseException
在我的WindowsPhone7.5应用程序中,我希望有一个包含数据模板的合并资源字典。为了实现这一点,我创建了一个名为“DataTemplates.xaml”的文件,并用DataTemplates填充它,如下所示:Windows phone 7 当我尝试加载一个充满数据模板的合并ResourceDictionary时,会出现一个XamlParseException,windows-phone-7,xaml,resourcedictionary,datatemplate,mergeddictionaries,Windows Phone 7,Xaml,Resourcedictionary,Datatemplate,Mergeddictionaries,在我的WindowsPhone7.5应用程序中,我希望有一个包含数据模板的合并资源字典。为了实现这一点,我创建了一个名为“DataTemplates.xaml”的文件,并用DataTemplates填充它,如下所示: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsof
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<DataTemplate x:Key="ItemTemplate">
<!-- xaml -->
</DataTemplate>
<DataTemplate x:Key="GroupHeaderTemplate">
<!-- xaml -->
</DataTemplate>
<DataTemplate x:Key="GroupItemTemplate" >
<!-- xaml -->
</DataTemplate>
</ResourceDictionary>
在我想使用DataTemplates的页面中,我编写了以下代码:
<phone:PhoneApplicationPage.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/myAssemblyName;component/Resources/DataTemplates.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</phone:PhoneApplicationPage.Resources>
但是,当我调试并尝试导航到包含ResourceDictionary的页面时,我得到了一个XamlParseException:未能分配到属性“System.Windows.ResourceDictionary.Source”
我该怎么办(谢谢!好的,我花了大约20分钟写这个问题,重读后我找到了解决方案,所以我回答自己:我不小心写了解决方案的名称空间而不是它的程序集名称!仅此而已,现在ResourceDictionary正确加载:)