'System.Windows.Markup.XamlParseException' in LongList

Dustin Hodges

New member
Jan 22, 2013
464
0
0
I'm currently trying to build a longlistselector that displays the users music albums using the XNA framework in a Windows Phone 8.1 Silverlight app. My problem is, whenever i enable grouping, if i scroll too fast through the list, the software will throw:
Code:
A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in System.Windows.ni.dll
Additional information:  [Line: 0 Position: 0]
To which i cant debug since the symbol file (System.Windows.pdb) is missing (and looking around suggests its missing on purpose since you can't debug the system).

This is a problem, since i need grouping enabled, but for some reason it's causing this exception. Anyone have any ideas?
 
Library Page Resources:
Code:
<phone:PhoneApplicationPage.Resources>
        <phone:JumpListItemBackgroundConverter x:Key="BackgroundConverter"/>
        <phone:JumpListItemForegroundConverter x:Key="ForegroundConverter"/>
        <Style x:Key="JumpListStyle" TargetType="phone:LongListSelector">
            <Setter Property="GridCellSize"  Value="113,113"/>
            <Setter Property="LayoutMode" Value="Grid" />
            <Setter Property="ItemTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <Border Background="{Binding Converter={StaticResource BackgroundConverter}}" Width="113" Height="113" 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>

        <DataTemplate x:Key="AlbumItem">
            <StackPanel Orientation="Horizontal" MaxWidth="460" MaxHeight="113" Margin="20,0,0,10">
                <Border Height="113" Width="113" Child="{Binding albumImage}" />
                <StackPanel Orientation="Vertical" Margin="10,0,0,0">
                        <TextBlock Text="{Binding albumName}" Foreground="White" FontSize="36" FontFamily="Segoe WP Black" TextTrimming="WordEllipsis"/>
                        <TextBlock Text="{Binding albumArtist}" Opacity="0.65" Foreground="White" FontFamily="Segoe WP Black" FontSize="24" TextTrimming="WordEllipsis"/>
                    </StackPanel>
                </StackPanel>
        </DataTemplate>

        <DataTemplate x:Key="GroupHeader">
            <Border Background="Transparent" Padding="0,10,5,5" Margin="20,0,0,0">
                <Grid Background="{StaticResource PhoneAccentBrush}" Width="62" 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"/>
                </Grid>
            </Border>
        </DataTemplate>
    </phone:PhoneApplicationPage.Resources>

List and it's enclosing panoramic pivot:
Code:
<phone:PivotItem Header="albums" x:Name="albumViewer">
                <Grid>
                    <phone:LongListSelector x:Name="albList" ItemTemplate="{StaticResource AlbumItem}" JumpListStyle="{StaticResource JumpListStyle}" GroupHeaderTemplate="{StaticResource GroupHeader}" HideEmptyGroups="True" IsGroupingEnabled="True" />
                </Grid>
            </phone:PivotItem>

Library CS file:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using Windows.Storage;
using System.Windows.Controls;
using System.Windows.Navigation;
using System.Threading;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using System.Windows.Resources;
using System.Windows.Media.Imaging;
using [B][COLOR="#B22222"][redacted][/COLOR][/B];
using System.Threading.Tasks;
using System.Windows.Media;

namespace [B][COLOR="#B22222"][redacted][/COLOR][/B]
{
    public partial class Library : PhoneApplicationPage
    {
        public Library()
        {
            InitializeComponent();
        }

        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            // Get Albums
            MediaLibrary Library = new MediaLibrary();
            List<AlbumList> source = new List<AlbumList>();
            AlbumCollection Albums = Library.Albums;

            foreach (Album album in Albums)
            {
                Image thumbnail = new Image();
                BitmapImage thumb = new BitmapImage();
                System.IO.Stream thumbnailStream = album.GetThumbnail();
                if (thumbnailStream != null)
                {
                    thumb.SetSource(thumbnailStream);
                }
                else
                {
                    thumb.UriSource = new Uri("/Assets/media/album.png", UriKind.Relative);
                }

                thumb.DecodePixelHeight = 113;
                thumb.DecodePixelWidth = 113;
                thumb.DecodePixelType = DecodePixelType.Logical;
                thumb.CreateOptions = BitmapCreateOptions.BackgroundCreation;
                thumb.CreateOptions = BitmapCreateOptions.DelayCreation;

                thumbnail.Source = thumb;
                thumbnail.Width = 113;
                thumbnail.Height = 113;
                thumbnail.Stretch = System.Windows.Media.Stretch.UniformToFill;

                source.Add(new AlbumList(thumbnail, album.Name.ToUpper(), album.Artist.Name.ToUpper()));

            }

            List<AlphaKeyGroup<AlbumList>> DataSource = AlphaKeyGroup<AlbumList>.CreateGroups(source, System.Threading.Thread.CurrentThread.CurrentUICulture, (AlbumList s) => { return s.albumName; }, true);
            albList.ItemsSource = DataSource;
        }

    }

    public class AlbumList
    {
        public string albumName { get; set; }
        public string albumArtist { get; set; }
        public Image albumImage { get; set; }

        public AlbumList(Image albumimage, string albumname, string albumartist)
        {
            this.albumName = albumname;
            this.albumArtist = albumartist;
            this.albumImage = albumimage;
        }
    }
}

And my alphaKeyGroup for grouping is borrowed from the Microsoft how-to: How to display data in a grouped list in LongListSelector for Windows Phone 8

(FYI: I'm not using any xml.)
 

Members online

No members online now.

Forum statistics

Threads
334,682
Messages
2,257,662
Members
428,725
Latest member
Infernodude74