1

我仍然没有在我的代码中发现问题。也许,可能无法将 alphakeygroep 绑定到 Observable Collection?

我正在编写一个使用 Longlistselector 和 JumpList 的 WP8 应用程序。绑定在使用 LongListSelector 而不使用 Jumplist 时有效。TrafficFeed 实现 INotifyPropertyChanged。xaml中的绑定如下:

ItemsSource="{绑定 feedsA}"

private ObservableCollection<TrafficFeed> feedsA = new ObservableCollection<TrafficFeed>();


public ObservableCollection<TrafficFeed> FeedsA
{
    get { return feedsA; }
    set { feedsA = value; }
}

当我添加 a 时JumpList,我需要将我的 observable 集合更改为:

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>

现在绑定不再起作用了。我应该添加什么?

4

0 回答 0