私の Windows Phone 7.5 アプリケーションでは、マージされた ResourceDictionary に DataTemplates を入力したいと考えています。これを実現するために、「DataTemplates.xaml」というファイルを作成し、次のように DataTemplates で埋めました。
<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: Failed to assign to property 'System.Windows.ResourceDictionary.Source' が発生しました。
どのようにできるのか?:( ありがとうございました!