在以下http://www.geekchamp.com/articles/all-about-resourcedictionary-in-wp7我想在我的应用程序中使用 ResourceDictionary。但是我在我的页面的 xaml 中收到一个错误,说我的应用程序根目录中的An error occurred while finding the resource dictionary "/Resources/ContactListDictionary.xaml". I have created a ResourceDictionary named
ContactListDictionary.xaml located in
Views/Resources` 子文件夹,我正在尝试将其添加到我的页面中,如下所示
<phone:PhoneApplicationPage.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Resources/ContactListDictionary.xaml"/> <!-- Error -->
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</phone:PhoneApplicationPage.Resources>
我错过了什么?我没有任何错误ContactListDictionary.xaml
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit">
<!-- Resource dictionary entries should be defined here. -->
<DataTemplate x:Key="ContactItemTemplate">
<Border HorizontalAlignment="Stretch" BorderBrush="#99FFFFFF" BorderThickness="1" Margin="0,10">
<StackPanel Margin="10" HorizontalAlignment="Stretch" >
<TextBlock Text="{Binding DisplayName}" Style="{StaticResource TextBlockTitleXLargeStyle}"/>
<TextBlock Text="{Binding Path=LocalizedResources.Resources_ContactListDictionary_PhoneNumbers, Source={StaticResource LocalizedStrings}}" Style="{StaticResource TextBlockTitleMediumStyle}"/>
<ListBox ItemsSource="{Binding PhoneNumbers}" Margin="12,0" ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="12,0,6,0" >
<!--<TextBlock Text="{Binding Kind}" Margin="12, 0, 6, 0" Style="{StaticResource TextBlockTitleMediumStyle}"/>-->
<TextBlock Text="{Binding PhoneNumber}" Style="{StaticResource TextBlockMediumStyle}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<TextBlock Text="{Binding Path=LocalizedResources.Resources_ContactListDictionary_EmailAddresses, Source={StaticResource LocalizedStrings}}" Style="{StaticResource TextBlockTitleMediumStyle}"/>
<ListBox ItemsSource="{Binding EmailAddresses}" Margin="12,0" ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="12,0,6,0">
<!--<TextBlock Text="{Binding Kind}" Margin="12, 0, 6, 0" Style="{StaticResource TextBlockTitleMediumStyle}"/>-->
<TextBlock Text="{Binding EmailAddress}" Style="{StaticResource TextBlockMediumStyle}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<TextBlock Text="{Binding Path=LocalizedResources.Resources_ContactListDictionary_Addresses, Source={StaticResource LocalizedStrings}}" Style="{StaticResource TextBlockTitleMediumStyle}"/>
<ListBox ItemsSource="{Binding Addresses}" Margin="12,0" ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="12,0,6,0">
<!--<TextBlock Text="{Binding Kind}" Margin="12, 0, 6, 0" Style="{StaticResource TextBlockTitleMediumStyle}" VerticalAlignment="Top"/>-->
<StackPanel>
<TextBlock Text="{Binding PhysicalAddress.AddressLine1}" Style="{StaticResource TextBlockMediumStyle}"/>
<TextBlock Text="{Binding PhysicalAddress.City}" Style="{StaticResource TextBlockMediumStyle}"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</Border>
</DataTemplate>
<DataTemplate x:Key="ContactsGroupHeaderTemplate">
<Border Background="{StaticResource PhoneAccentBrush}" Padding="{StaticResource PhoneTouchTargetOverhang}">
<TextBlock Text="{Binding Title}" Style="{StaticResource PhoneTextLargeStyle}"/>
</Border>
</DataTemplate>
<DataTemplate x:Key="ContactsGroupItemTemplate" >
<Border Background="{StaticResource PhoneAccentBrush}" Margin="{StaticResource PhoneTouchTargetOverhang}" Padding="{StaticResource PhoneTouchTargetOverhang}">
<TextBlock Text="{Binding Title}" Style="{StaticResource PhoneTextLargeStyle}"/>
</Border>
</DataTemplate>
<ItemsPanelTemplate x:Key="ContactGroupViewTemplate">
<toolkit:WrapPanel/>
</ItemsPanelTemplate>
</ResourceDictionary>