<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar Mode="Minimized">
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem x:Name="copyQuote" Text="Copy Quote" Click="copyText"/>
<shell:ApplicationBarMenuItem x:Name="deleteAllFavs" Text="Delete All" Click="delete_All_Favs"/>
<shell:ApplicationBarMenuItem x:Name="rateAndReview" Text="Rate and Review" Click="rateApp"/>
<shell:ApplicationBarMenuItem x:Name="suggestions" Text="suggestions" Click="emailSuggestion"/>
</shell:ApplicationBar.MenuItems>
<shell:ApplicationBarIconButton x:Name="message" IconUri="/icons/appbar.feature.email.rest.png" Text="message" Click="message_favourite"/>
<shell:ApplicationBarIconButton x:Name="share" IconUri="/icons/appbar.message.send.png" Text="share" Click="share_favorite"/>
<shell:ApplicationBarIconButton x:Name="deleteFav" IconUri="/icons/appbar.delete.rest.png" Text="delete" Click="delete_favorite"/>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="90"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="2" Margin="12,0,12,0">
<ListBox Height="Auto" HorizontalAlignment="Left" Margin="-12,0,0,0" x:Name="favShaListBox" VerticalAlignment="Top" Width="Auto" FontFamily="Yu Gothic" FontWeight="Bold" RenderTransformOrigin="0.5,0.5" HorizontalContentAlignment="Stretch" ItemsSource="{Binding}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Content}" TextWrapping="Wrap" FontSize="24" FontFamily="Yu Gothic" Width="480" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Name" Value="{Binding QuoteKey}"/>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
</Grid>
当我尝试加载这个xaml页面时,它会抛出一个名为XAML parseException的异常,指向Setter中的属性“Value”,用于为上面的Listbox设置样式。
$ exception {“Set property''抛出异常。[Line:50 Position:49]”} System.Exception {System.Windows.Markup.XamlParseException}
它指向一个应用程序栏项名称“copyQuote”,其中我明确指出样式目标只有ListboxItem。
答案 0 :(得分:0)
我认为设置ListboxItem的属性存在问题。
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Name" Value="{Binding QuoteKey}"/>
</Style>
</ListBox.ItemContainerStyle>
删除此Setter
后尝试。