-1
在我的Windows Phone 7.5應用程序中,我希望有一個合併的ResourceDictionary用DataTemplates填充。爲了實現這一目標,我創建了一個名爲「DataTemplates.xaml」的文件,並用這樣的DataTemplates填充它:當我嘗試加載用DataTemplates填充的合併ResourceDictionary時,出現XamlParseException
<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'
我該怎麼辦? (謝謝!