longlist grouped data not showing correctly

Daniel Affleck

New member
Apr 11, 2014
1
0
0
Visit site
This has been driving me nuts - missing something simple i know - but dont want to waste any more time if possible. have a long list on my page with its data source set thus:

Code:
  var result = (from s in App.ViewModel.AllSampleData
                      join j in App.ViewModel.AllJobData
                      on s.SampleJobID equals j.JobID
                      select new { j.JobNumber, s.SampleNumber }).GroupBy(j => j.JobNumber).ToList();

        this.lstSamples.ItemsSource = result;

the markup is as follows:

Code:
      <phone:LongListSelector
            x:Name="lstJobSamplesGrouped"
            IsGroupingEnabled="True"
            GroupHeaderTemplate="{StaticResource GroupHeaderTemplate}"
            ItemTemplate="{StaticResource SampleTemplate}"
            LayoutMode="List"
            HorizontalAlignment="Left" Margin="10,10,0,10" 
            Width="436" Tap="lstSamples_Tap"/>

and the templates thus:

Code:
<phone:PhoneApplicationPage.Resources>
    <DataTemplate x:Key="GroupHeaderTemplate">
        <StackPanel VerticalAlignment="Top">
            <TextBlock FontWeight="Bold" FontSize="26"  Text="{Binding Key}" />
        </StackPanel>
    </DataTemplate>
    <DataTemplate x:Key="SampleTemplate">
        <StackPanel VerticalAlignment="Top">
            <TextBlock FontWeight="Bold" FontSize="26"  Text="{Binding SampleNumber}" />
        </StackPanel>
    </DataTemplate>
</phone:PhoneApplicationPage.Resources>

the key displays fine, but the grouped items are not showing:

should show something like this -

A2000
001
002
003
A2001
001
002

but I get just

A2000
A2001
A2002

perhaps someone could shed some light on this for me

many thanks :)
 

Laura Knotek

Retired Moderator
Mar 31, 2012
29,405
24
38
Visit site
Hi Daniel and welcome to WPCentral.

I've moved your thread to the Developers Corner forum, since this is something that developers will be better able to help you with than regular users.
 

Catholic Tech Geek

New member
Feb 2, 2012
130
0
0
Visit site
Ok, for LongListSelector, what you need depends on which os you are developing for. Unless you tell me differently, I am assuming you are developing a program for Windows Phone 8. First, you need to have the IsGroupingEnabled property set to true. LongListSelector in Windows Phone 8 requires 3 parts: ItemTemplate, GroupHeaderTemplate, and JumpListStyle. ItemTemplate is for each item in a group. GroupHeaderTemplate is for each group "header". JumpListStyle is a style, not a DataTemplate (like the other 2). JumpListStyle is what is shown when the user wants to select a group to scroll to. It is made up of 3 parts: LayoutMode, which is either grid or list, ItemTemplate, and (if you chose grid for the JumpListStyle) GridCellSize.

Looking at your code above, I find no issue with your C# code behind. However, in your XAML, you are missing the JumpListStyle property. If you are unsure of anything, check out the documentation for LongListSelector on MSDN.
 

Catholic Tech Geek

New member
Feb 2, 2012
130
0
0
Visit site
Ok, for LongListSelector, what you need depends on which os you are developing for. Unless you tell me differently, I am assuming you are developing a program for Windows Phone 8. First, you need to have the IsGroupingEnabled property set to true. LongListSelector in Windows Phone 8 requires 3 parts: ItemTemplate, GroupHeaderTemplate, and JumpListStyle. ItemTemplate is for each item in a group. GroupHeaderTemplate is for each group "header". JumpListStyle is a style, not a DataTemplate (like the other 2). JumpListStyle is what is shown when the user wants to select a group to scroll to. It is made up of 3 parts: LayoutMode, which is either grid or list, ItemTemplate, and (if you chose grid for the JumpListStyle) GridCellSize.

Looking at your code above, I find no issue with your C# code behind. However, in your XAML, you are missing the JumpListStyle property. If you are unsure of anything, check out the documentation for LongListSelector on MSDN.
 

Members online

Forum statistics

Threads
323,278
Messages
2,243,563
Members
428,054
Latest member
BevitalGlucoPremium