简体   繁体   English

使用SemanticZoom的JumpList在Windows Phone 8.1中不起作用

[英]JumpList using SemanticZoom not working in Windows Phone 8.1

I followed the tutorial on this page: http://modernography.wordpress.com/2014/04/26/jumplists-in-windows-phone-8-1/ 我遵循了此页面上的教程: http : //modernography.wordpress.com/2014/04/26/jumplists-in-windows-phone-8-1/

I have a collectionviewsource: 我有一个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;
    }
}

Which I bind to my XAML: 我绑定到我的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>

It all displays correctly, I can open and close the JumpList. 一切都正确显示,我可以打开和关闭JumpList。 BUT, when I tap on a letter in the zoomedoutview, the zoomedinview doesn't jump to that letter. 但是,当我在zoomedoutview中点击一个字母时,zoomedinview不会跳到该字母。 Instead, it stays where it was? 相反,它留在原地了吗?

I can't find the cause for this problem. 我找不到导致此问题的原因。 Maybe the problem is that the SementicZoom is inside a Pivot? 也许问题在于SementicZoom位于枢轴内部?

I think the issue is caused because ListView and GridView are obtaining different instances of CollectionView. 我认为是由于ListView和GridView获取不同的CollectionView实例引起的。 As the example shows, you should cache the first created instance. 如示例所示,您应该缓存第一个创建的实例。

The code should be: 代码应为:

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;
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM