我正在为一个项目构建WP8应用程序,它基本上从Web导入XML文件并在LongListSelector中显示内容。
这是我的XAML代码
<phone:PhoneApplicationPage
x:Class="TestApp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<phone:LongListSelector x:Name="lb_country_list"
LayoutMode="List"
IsGroupingEnabled="true"
HideEmptyGroups ="true"
HorizontalAlignment="Left"
Height="655"
Margin="10,10,0,0"
VerticalAlignment="Top"
Width="436"
ItemTemplate="{StaticResource LLSItemTemplate}"/>
<Button Content="Get Data" HorizontalAlignment="Left" Height="88" Margin="125,670,0,0" VerticalAlignment="Top" Width="221"/>
</Grid>
</Grid>
<phone:PhoneApplicationPage.Resources>
<DataTemplate x:Key="LLSItemTemplate">
<StackPanel>
<TextBlock Margin="10"
Text="{Binding country_namef}"
TextWrapping="Wrap"
Foreground="Black"/>
<Line Grid.Row="1" X1="0" X2="480" Y1="0" Y2="0" Stroke="Gray" Margin="0"/>
</StackPanel>
</DataTemplate>
</phone:PhoneApplicationPage.Resources>
我收到以下错误。
A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in System.Windows.ni.dll
Additional information: Cannot find a Resource with the Name/Key LLSItemTemplate [Line: 32 Position: 50]
在MainPage.xaml.vb中的InitializeComponent()
答案 0 :(得分:0)
附加信息确切地说明了错误:解析器无法找到资源LLSItemTemplate
。您应该在LongListSelector
或MainPage.xaml
中包含App.xaml
的itemtemplate。