【问题标题】:JumpList using SemanticZoom not working in Windows Phone 8.1使用 SemanticZoom 的 JumpList 在 Windows Phone 8.1 中不起作用
【发布时间】:2014-06-12 14:26:53
【问题描述】:

我按照此页面上的教程进行操作:http://modernography.wordpress.com/2014/04/26/jumplists-in-windows-phone-8-1/

我有一个collectionviewsource:

// artistdata
public CollectionViewSource ArtistList
{
    get
    {
        var data = App.musicdata.Artists;
        var groups = data.ToAlphaGroups(x => x.name);
        _ArtistList = new CollectionViewSource();
        _ArtistList.Source = groups; //groups is the result of using my extension methods above
        _ArtistList.IsSourceGrouped = true;

        return _ArtistList;
    }
}

我绑定到我的 XAML:

<PivotItem x:Name="artists" Margin="10,0">
    <SemanticZoom Style="{StaticResource AlphaJumpListStyle}">
        <SemanticZoom.ZoomedInView>
            <ListView Background="Transparent" ItemsSource="{Binding ArtistList.View}" Loaded="ListviewLoaded">
                <ListView.GroupStyle>
                    <GroupStyle HeaderTemplate="{StaticResource AlphaGroupHeaderTemplate}" HeaderContainerStyle="{StaticResource JumpListListHeaderContainerStyle}" HidesIfEmpty="True" />
                </ListView.GroupStyle>
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Grid.Column="1" Margin="10,5" Tapped="ArtistSelected">
                            <TextBlock FontFamily="Segoe WP" FontSize="22" Foreground="White" Text="{Binding name}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="{Binding ActualWidth, ElementName=parentElementName}"/>
                            <TextBlock FontFamily="Segoe WP" FontWeight="Light" FontSize="17" Foreground="#7FFFFFFF" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,-5,0,0">
                        <Run Text="{Binding amountofalbums}"/>
                        <Run Text="albums"/>
                            </TextBlock>
                        </StackPanel>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </SemanticZoom.ZoomedInView>
        <SemanticZoom.ZoomedOutView>
            <GridView ItemsSource="{Binding ArtistList.View.CollectionGroups}" Style="{StaticResource AlphaJumpListPickerStyle}" />
        </SemanticZoom.ZoomedOutView>
    </SemanticZoom>
</PivotItem>

一切正常,我可以打开和关闭 JumpList。 但是,当我在 zoomedoutview 中点击一个字母时,zoomedinview 不会跳到那个字母。相反,它会停留在原来的位置?

我找不到这个问题的原因。也许问题在于 SementicZoom 在 Pivot 内?

【问题讨论】:

    标签: c# xaml windows-phone-8 winrt-xaml windows-phone-8.1


    【解决方案1】:

    我认为这个问题是因为 ListView 和 GridView 正在获取不同的 CollectionView 实例。如示例所示,您应该缓存第一个创建的实例。

    代码应该是:

    public CollectionViewSource ArtistList
    {
        get
        {
            if(_ArtistList == null)
            {
                var data = App.musicdata.Artists;
                var groups = data.ToAlphaGroups(x => x.name);
                _ArtistList = new CollectionViewSource();
                _ArtistList.Source = groups; //groups is the result of using my extension methods above
                _ArtistList.IsSourceGrouped = true;
            }
            return _ArtistList;
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-12-13
      • 1970-01-01
      • 1970-01-01
      • 2015-02-23
      • 1970-01-01
      • 1970-01-01
      • 2014-06-25
      相关资源
      最近更新 更多