So I'm working on WP8 app and I'm trying to figure out to get my LongListSelector to show custom groups. Basically what I have is a section where messages will be displayed but messages can be generated from 2 different places in the web application so they need to be grouped in the appropriate categories (Alerts and BTR's). I tried going through the example code that is on MSDN but since it's only in C# I'm getting stuck on certain parts and right now my LLS is only showing one item from the list. I think it has something to do with me not using the AlphaKeyGroup that is referenced in the example (but again I can't really use it since I'm not sorting by a character in the messages but instead there's an type value that is passed from the Webservice). Below is my XAML code for the LLS and the Date Templates
<!--Panorama item one-->
<phone:PanoramaItem x:Name="item1" Header="Messages">
<phone:LongListSelector x:Name="messageList"
LayoutMode="List"
GroupHeaderTemplate="{StaticResource MessagesHeaderTemplate}"
ItemTemplate="{StaticResource AlertMessageTemplate}" IsGroupingEnabled="True"/>
</phone:PanoramaItem>
<!-- Template for Alert Messages-->
<DataTemplate x:Key="AlertMessageTemplate">
<StackPanel VerticalAlignment="Top">
<TextBlock Text="{Binding AlertDate}" Foreground="Black"/>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="MessagesHeaderTemplate">
<Border Background="Transparent" Padding="5">
<Border Background="#FF27AAE1" Margin="0,0,18,0" HorizontalAlignment="Left">
<TextBlock Text="{Binding MessageGroup}" Foreground="White" FontSize="48" Padding="6"
FontFamily="{StaticResource PhoneFontFamilySemiLight}" HorizontalAlignment="Left" VerticalAlignment="Center"/>
</Border>
</Border>
</DataTemplate>
And here is the VB code that I'm using just to create a quick test with a Group value and a date (in the actual working version there will be three pieces of text that are displayed and the type value can be an integer or string if one is easier than the other to work with in this scenario).
Private Sub SetupMessageList()
Dim source As New List(Of AlertMessage)()
source.Add(New AlertMessage("Alert", "10/01/2010"))
source.Add(New AlertMessage("Alert", "11/01/2010"))
source.Add(New AlertMessage("Alert", "2/15/2012"))
source.Add(New AlertMessage("Alert", "3/15/2013"))
source.Add(New AlertMessage("BTR", "10/01/2010"))
source.Add(New AlertMessage("BTR", "11/01/2010"))
source.Add(New AlertMessage("BTR", "2/15/2012"))
source.Add(New AlertMessage("BTR", "3/15/2013"))
messageList.ItemsSource = source
End Sub
'Class For building Alert Messages from Web Service
Public Class AlertMessage
Private m_MessageGroup As String
Public Property MessageGroup As String
Get
Return m_MessageGroup
End Get
Set(value As String)
m_MessageGroup = value
End Set
End Property
Private m_AlertDate As String
Public Property AlertDate As String
Get
Return m_AlertDate
End Get
Set(value As String)
m_AlertDate = value
End Set
End Property
Public Sub New(messagegroup As String, alertdate As String)
Me.MessageGroup = messagegroup
Me.AlertDate = alertdate
End Sub
End Class
So I was able to figure it out using a custom string key group that would let me choose what string I want to use as a Key. I'm posting it below in case anyone else wants it: