我仍然没有在我的代码中发现问题。也许,可能无法将alphakeygroep绑定到Observable Collection?
我正在编写一个使用带有JumpList的Longlistselector的WP8应用程序。 在不使用Jumplist的情况下使用LongListSelector时绑定有效。 TrafficFeed实现了INotifyPropertyChanged。 xaml中的绑定如下:
ItemsSource =“{Binding feedsA}”
private ObservableCollection<TrafficFeed> feedsA = new ObservableCollection<TrafficFeed>();
public ObservableCollection<TrafficFeed> FeedsA
{
get { return feedsA; }
set { feedsA = value; }
}
当我添加JumpList
时,我需要将我的可观察集合更改为:
private ObservableCollection<AlphaKeyGroup<TrafficFeed>> dataSourceAntwerpen = new ObservableCollection<AlphaKeyGroup<TrafficFeed>>();
public ObservableCollection<AlphaKeyGroup<TrafficFeed>> DataSourceAntwerpen
{
get { return dataSourceAntwerpen; }
set { dataSourceAntwerpen = value; }
}
<phone:PivotItem Header="item2">
<phone:LongListSelector SelectionChanged="feedListBox_SelectionChanged"
ItemsSource="{Binding DataSourceAntwerpen}"
x:Name="LongListfeedsA"
JumpListStyle="{StaticResource AddrBookJumpListStyle}"
Background="Transparent"
GroupHeaderTemplate="{StaticResource AddrBookGroupHeaderTemplate}"
ItemTemplate="{StaticResource AddrBookItemTemplate}"
LayoutMode="List"
IsGroupingEnabled="true"
HideEmptyGroups ="true"/>
<phone:PhoneApplicationPage.Resources>
<DataTemplate x:Key="AddrBookItemTemplate">
<StackPanel VerticalAlignment="Top">
<TextBlock TextDecorations="Underline" FontSize="24" Name="feedTitle" TextWrapping="Wrap" Margin="12,0,0,0" HorizontalAlignment="Left" Foreground="{StaticResource PhoneAccentBrush}" Text="{Binding Title}" />
<TextBlock Name="feedSummary" TextWrapping="Wrap" Margin="12,0,0,0" Text="{Binding Description}" />
<TextBlock Name="feedPubDate" Foreground="{StaticResource PhoneSubtleBrush}" Margin="12,0,0,10" Text="{Binding PubDate}" />
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="AddrBookGroupHeaderTemplate">
<Border Background="Transparent" Padding="5">
<Border Background="{StaticResource PhoneAccentBrush}" BorderBrush="{StaticResource PhoneAccentBrush}" BorderThickness="2" Width="auto"
Height="62" Margin="0,0,18,0" HorizontalAlignment="Left">
<TextBlock Text="{Binding Key}" Foreground="{StaticResource PhoneForegroundBrush}" FontSize="48" Padding="6"
FontFamily="{StaticResource PhoneFontFamilySemiLight}" HorizontalAlignment="Left" VerticalAlignment="Center"/>
</Border>
</Border>
</DataTemplate>
<phone:JumpListItemBackgroundConverter x:Key="BackgroundConverter"/>
<phone:JumpListItemForegroundConverter x:Key="ForegroundConverter"/>
<Style x:Key="AddrBookJumpListStyle" TargetType="phone:LongListSelector">
<Setter Property="GridCellSize" Value="200,100"/>
<Setter Property="LayoutMode" Value="Grid" />
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<Border Background="{Binding Converter={StaticResource BackgroundConverter}}" Width="200" Height="100" Margin="6" >
<TextBlock Text="{Binding Key}" FontFamily="{StaticResource PhoneFontFamilySemiBold}" FontSize="48" Padding="6"
Foreground="{Binding Converter={StaticResource ForegroundConverter}}" VerticalAlignment="Center"/>
</Border>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</phone:PhoneApplicationPage.Resources>
现在绑定不再起作用了。我应该添加什么?