none
LongListSelector

    Question

  • Hello,

    I am developing a Windows Phone 7 app that contains a LongListSelector by following the tutorial from the link below but in Visual Basic:

    http://dotnetspeaks.com/DisplayArticle.aspx?ID=215

    However there are some errors that have occurred which I don't know how to fix. Can anyone help resolve them please? All help would be appreciated.

    Thanks

    Wednesday, August 28, 2013 11:36 AM

Answers

  • Hello Guys,

    >>Range variable 'GroupBy' hides a variable in an enclosing block or a range variable previously defined in the query expression.

    From this error message, Please Ensure that all variables in your lambda expression have unique names that do not duplicate existing variable names in the same scope.

    I create a sample on my side. And Renamed JumpDemo Class GroupBy Property -> SGroupBy. Something looks like this,

    VB.NET Code:

        Public Class Group(Of T)
            Implements IEnumerable(Of T)
    
            Public Sub New(name As String, items As IEnumerable(Of T))
                Me.Title = name
                Me.Items = New List(Of T)(items)
            End Sub
    
            Public Overrides Function Equals(obj As Object) As Boolean
                Dim that As Group(Of T) = TryCast(obj, Group(Of T))
                Return (that IsNot Nothing) AndAlso (Me.Title.Equals(that.Title))
            End Function
    
            Public Property Title() As String
                Get
                    Return m_Title
                End Get
                Set(value As String)
                    m_Title = value
                End Set
            End Property
            Private m_Title As String
    
            Public Property Items() As IList(Of T)
                Get
                    Return m_Items
                End Get
                Set(value As IList(Of T))
                    m_Items = value
                End Set
            End Property
            Private m_Items As IList(Of T)
    
            Public Function GetEnumerator() As IEnumerator(Of T) Implements IEnumerable(Of T).GetEnumerator
                Return Me.Items.GetEnumerator()
            End Function
    
            Private Function System_Collections_IEnumerable_GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
                Return Me.Items.GetEnumerator()
            End Function
        End Class
    
        Public Class JumpDemo
            Public Property Name() As String
                Get
                    Return m_Name
                End Get
                Set(value As String)
                    m_Name = Value
                End Set
            End Property
            Private m_Name As String
    
            Public Property SGroupBy() As String
                Get
                    Return m_GroupBy
                End Get
                Set(value As String)
                    m_GroupBy = value
                End Set
            End Property
            Private m_GroupBy As String
        End Class
            Dim source As New List(Of JumpDemo)()
            source.Add(New JumpDemo() With { _
            .Name = "A-Name 1", _
            .SGroupBy = "A" _
            })
            source.Add(New JumpDemo() With { _
                .Name = "A-Name 2", _
                .SGroupBy = "A" _
            })
            source.Add(New JumpDemo() With { _
                .Name = "A-Name 3", _
                .SGroupBy = "A" _
            })
    
            Dim groupBy = From jumpdemo In source Group jumpdemo By jumpdemo.SGroupBy Into c = Group Order By SGroupBy Select New Group(Of JumpDemo)(SGroupBy, c)

    It works fine on my side. I suggested you to modify you code like me.

    Here are some references about LINQ, I recommended it to you.

    #101 LINQ Samples

    http://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b

    Regards,


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Friday, August 30, 2013 9:02 AM

All replies

  • Hello Guys,

    According to your code screenshot, I understood there is an issue regarding LINQ and 

    IEnumerable<T> interface.

    I created a sample to reproduce this issue on my side. But I failed. I suggested you to provide a simplified example for us to reproduce the issue. it will help us to figure out this issue better.

    From your code screenshot, I noticed there were some error message.

    >>Class 'Group' must implement 'Function GetEnumerator() As IEnumerator(Of T)' for interface 'System.Collections.Generic.IEnumerable(Of T)'

    In general, From this error message, I suggested you to set ‘Group’ Class implement

    IEnumerable<T> interface. Something looks like,

    Public Class Group(Of T)
            Implements IEnumerable(Of T)
    
            Public Sub New(name As String, items As IEnumerable(Of T))
                Me.Title = name
                Me.Items = New List(Of T)(items)
            End Sub
    
            Public Overrides Function Equals(obj As Object) As Boolean
                Dim that As Group(Of T) = TryCast(obj, Group(Of T))
                Return (that IsNot Nothing) AndAlso (Me.Title.Equals(that.Title))
            End Function
    
            Public Property Title() As String
                Get
                    Return m_Title
                End Get
                Set(value As String)
                    m_Title = value
                End Set
            End Property
            Private m_Title As String
    
            Public Property Items() As IList(Of T)
                Get
                    Return m_Items
                End Get
                Set(value As IList(Of T))
                    m_Items = value
                End Set
            End Property
            Private m_Items As IList(Of T)
    
            Public Function GetEnumerator() As IEnumerator(Of T) Implements IEnumerable(Of T).GetEnumerator
                Return Me.Items.GetEnumerator()
            End Function
    
            Private Function System_Collections_IEnumerable_GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
                Return Me.Items.GetEnumerator()
            End Function
        End Class

    >>Type 'Microsoft.Phone.Controls.LongListSelector' is not defined

    I think this application has not contained LongListSelector control. please add this

    control to the application.

    If you need to more assistance or I misunderstood, please feel free to let me know.

    Regards,


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, August 29, 2013 3:15 AM
  • Make sure you have the tow lines below at the top of you r module.  Also add the Reference fro phone control to the project from the menu : Project - Add Referenece.  LongListControl is part of Framework so you have to add the reference "PresentationFrameWork" on the Net Tab.

    Imports System.Linq
    Imports Microsoft.Phone.Controls


    jdweng

    Thursday, August 29, 2013 4:52 AM
  • OK 2 errors were resolved, just 1 error remains:

    Friday, August 30, 2013 8:41 AM
  • Hello Guys,

    >>Range variable 'GroupBy' hides a variable in an enclosing block or a range variable previously defined in the query expression.

    From this error message, Please Ensure that all variables in your lambda expression have unique names that do not duplicate existing variable names in the same scope.

    I create a sample on my side. And Renamed JumpDemo Class GroupBy Property -> SGroupBy. Something looks like this,

    VB.NET Code:

        Public Class Group(Of T)
            Implements IEnumerable(Of T)
    
            Public Sub New(name As String, items As IEnumerable(Of T))
                Me.Title = name
                Me.Items = New List(Of T)(items)
            End Sub
    
            Public Overrides Function Equals(obj As Object) As Boolean
                Dim that As Group(Of T) = TryCast(obj, Group(Of T))
                Return (that IsNot Nothing) AndAlso (Me.Title.Equals(that.Title))
            End Function
    
            Public Property Title() As String
                Get
                    Return m_Title
                End Get
                Set(value As String)
                    m_Title = value
                End Set
            End Property
            Private m_Title As String
    
            Public Property Items() As IList(Of T)
                Get
                    Return m_Items
                End Get
                Set(value As IList(Of T))
                    m_Items = value
                End Set
            End Property
            Private m_Items As IList(Of T)
    
            Public Function GetEnumerator() As IEnumerator(Of T) Implements IEnumerable(Of T).GetEnumerator
                Return Me.Items.GetEnumerator()
            End Function
    
            Private Function System_Collections_IEnumerable_GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
                Return Me.Items.GetEnumerator()
            End Function
        End Class
    
        Public Class JumpDemo
            Public Property Name() As String
                Get
                    Return m_Name
                End Get
                Set(value As String)
                    m_Name = Value
                End Set
            End Property
            Private m_Name As String
    
            Public Property SGroupBy() As String
                Get
                    Return m_GroupBy
                End Get
                Set(value As String)
                    m_GroupBy = value
                End Set
            End Property
            Private m_GroupBy As String
        End Class
            Dim source As New List(Of JumpDemo)()
            source.Add(New JumpDemo() With { _
            .Name = "A-Name 1", _
            .SGroupBy = "A" _
            })
            source.Add(New JumpDemo() With { _
                .Name = "A-Name 2", _
                .SGroupBy = "A" _
            })
            source.Add(New JumpDemo() With { _
                .Name = "A-Name 3", _
                .SGroupBy = "A" _
            })
    
            Dim groupBy = From jumpdemo In source Group jumpdemo By jumpdemo.SGroupBy Into c = Group Order By SGroupBy Select New Group(Of JumpDemo)(SGroupBy, c)

    It works fine on my side. I suggested you to modify you code like me.

    Here are some references about LINQ, I recommended it to you.

    #101 LINQ Samples

    http://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b

    Regards,


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Friday, August 30, 2013 9:02 AM
  • You have to change the following

    From : Dim GroupBy

    To : Dim MyGroupBy

    After I made the change I got additional errors.  Made a quick test project to eliminate all the errors.  The code below isn't tested and I just put together quickly to get rid of the compiler errors.  I don't think it will work.  The generic GroupBy method required one parameter so I had to create a custom class which didn't have a parameter for the GroupBy() method not to give an error.

    Module Module1
        Dim source As List(Of Jumpdemo) = New List(Of Jumpdemo)
        Sub Main()
            Dim MyGroupBy = From jumpdemo In source _
                  Group jumpdemo By jumpdemo.GroupBy Into c = Group _
                  Order By GroupBy _
                  Select New  _
                  KeyValuePair(Of List(Of String), Jumpdemo)(GroupBy, c)
        End Sub
        Class Jumpdemo
            Function GroupBy() As List(Of String)
                Dim results As List(Of String) = New List(Of String)
                Return results
            End Function
        End Class
    End Module


    jdweng

    Friday, August 30, 2013 10:06 AM
  • Sorry but I don't understand. What in this code needs to change?

    Imports System.Linq
    Imports Microsoft.Phone.Controls
    Partial Public Class MainPage
        Inherits PhoneApplicationPage
    
        ' Constructor
        Public Sub New()
            InitializeComponent()
    
            Dim source As New List(Of JumpDemo)()
            source.Add(New JumpDemo() With { _
                .Name = "A-Name 1", _
                .GroupBy = "A" _
            })
            source.Add(New JumpDemo() With { _
                .Name = "A-Name 2", _
                .GroupBy = "A" _
            })
            source.Add(New JumpDemo() With { _
                .Name = "A-Name 3", _
                .GroupBy = "A" _
            })
            source.Add(New JumpDemo() With { _
                .Name = "A-Name 4", _
                .GroupBy = "A" _
            })
            source.Add(New JumpDemo() With { _
                .Name = "A-Name 5", _
                .GroupBy = "A" _
            })
            source.Add(New JumpDemo() With { _
                .Name = "B-Name 1", _
                .GroupBy = "B" _
            })
            source.Add(New JumpDemo() With { _
                .Name = "B-Name 2", _
                .GroupBy = "B" _
            })
            source.Add(New JumpDemo() With { _
                .Name = "C-Name 1", _
                .GroupBy = "C" _
            })
            source.Add(New JumpDemo() With { _
                .Name = "C-Name 2", _
                .GroupBy = "C" _
            })
            source.Add(New JumpDemo() With { _
                .Name = "C-Name 3", _
                .GroupBy = "C" _
            })
            source.Add(New JumpDemo() With { _
                .Name = "C-Name 4", _
                .GroupBy = "C" _
            })
            source.Add(New JumpDemo() With { _
                .Name = "D-Name 1", _
                .GroupBy = "D" _
            })
            source.Add(New JumpDemo() With { _
                .Name = "D-Name 2", _
                .GroupBy = "D" _
            })
            source.Add(New JumpDemo() With { _
                .Name = "D-Name 3", _
                .GroupBy = "D" _
            })
            source.Add(New JumpDemo() With { _
                .Name = "E-Name 1", _
                .GroupBy = "E" _
            })
            source.Add(New JumpDemo() With { _
                .Name = "E-Name 2", _
                .GroupBy = "E" _
            })
            source.Add(New JumpDemo() With { _
                .Name = "F-Name 2", _
                .GroupBy = "F" _
            })
            source.Add(New JumpDemo() With { _
                .Name = "G-Name 2", _
                .GroupBy = "G" _
            })
            source.Add(New JumpDemo() With { _
                .Name = "G-Name 2", _
                .GroupBy = "G" _
            })
    
            Dim groupBy = From jumpdemo In source _
                          Group jumpdemo By jumpdemo.GroupBy Into c = Group _
                          Order By GroupBy _
                          Select New  _
                          Group(Of JumpDemo)(GroupBy, c)
    
            Me.citiesListGroups.ItemsSource = groupBy
        End Sub
    
        Private Sub tap_JumpListItem(sender As Object, e As System.Windows.Input.GestureEventArgs)
            Dim hb As TextBlock = TryCast(sender, TextBlock)
            MessageBox.Show(hb.Text + " " + "tapped")
        End Sub
    End Class
    
    
    Public Class Group(Of T)
        Implements IEnumerable(Of T)
        Public Sub New(name As String, items As IEnumerable(Of T))
            Me.Title = name
            Me.Items = New List(Of T)(items)
        End Sub
        Public Overrides Function Equals(obj As Object) As Boolean
            Dim that As Group(Of T) = TryCast(obj, Group(Of T))
            Return (that IsNot Nothing) AndAlso (Me.Title.Equals(that.Title))
        End Function
        Public Property Title() As String
            Get
                Return m_Title
            End Get
            Set(value As String)
                m_Title = Value
            End Set
        End Property
        Private m_Title As String
        Public Property Items() As IList(Of T)
            Get
                Return m_Items
            End Get
            Set(value As IList(Of T))
                m_Items = Value
            End Set
        End Property
        Private m_Items As IList(Of T)
        Public Function GetEnumerator() As IEnumerator(Of T) Implements IEnumerable(Of T).GetEnumerator
            Return Me.Items.GetEnumerator()
        End Function
        Private Function System_Collections_IEnumerable_GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
            Return Me.Items.GetEnumerator()
        End Function
    End Class
    
    
    Public Class JumpDemo
        Public Property Name() As String
            Get
                Return m_Name
            End Get
            Set(value As String)
                m_Name = Value
            End Set
        End Property
        Private m_Name As String
    
    
        Public Property GroupBy() As String
            Get
                Return m_GroupBy
            End Get
            Set(value As String)
                m_GroupBy = Value
            End Set
        End Property
        Private m_GroupBy As String
    End Class
    
    Friday, August 30, 2013 1:52 PM
  • From :

    Dim groupBy = From jumpdemo In source _
                          Group jumpdemo By jumpdemo
    .GroupBy Into c = Group _
                          Order By GroupBy _
                         
    Select New  _
                          Group
    (Of JumpDemo)(GroupBy, c)

    To :

    Dim MygroupBy = From jumpdemo In source _
                          Group jumpdemo By jumpdemo
    .GroupBy Into c = Group _
                          Order By GroupBy _
                         
    Select New  _
                          Group
    (Of JumpDemo)(GroupBy, c)


    jdweng

    Friday, August 30, 2013 4:14 PM
  • OK just 1 error left:

    Friday, August 30, 2013 4:23 PM
  • Yes! I thought that would be obvious.  Since you changed Groupby to MyGroupBy on the ine above you have to make the same change on the line you are getting the error.

    jdweng

    Friday, August 30, 2013 8:17 PM
  • OK thanks. How can I generate different button click methods for each LLS item?
    Sunday, September 01, 2013 6:15 AM
  • Do a search at www.google.com for th efollowing

    longlistselector event button

    There are a number of different comments in the hits from stackoverflow that you would be interested in .


    jdweng

    Sunday, September 01, 2013 6:52 AM
  • Is there anyway of getting all the letters of the alphabet to appears and to have certain letters greyed out? (For those letters which don't have any items beginning with that letter)
    Sunday, September 01, 2013 8:23 AM
  • I've tried to implement another LLS within my project but I get this error:

    LLS No. 1

    Imports System.Linq
    Imports Microsoft.Phone.Controls
    
    Partial Public Class Victoria_line
        Inherits PhoneApplicationPage
    
        Public Sub New()
            InitializeComponent()
            Dim source As New List(Of Victoria)()
            source.Add(New Victoria() With { _
                .Name = "Blackhorse Road", _
                .FareZone = "Fare zone 3", _
                .GroupBy = "b" _
            })
            source.Add(New Victoria() With { _
                .Name = "Brixton", _
                .FareZone = "Fare zone 2", _
                .GroupBy = "b" _
            })
            source.Add(New Victoria() With { _
                .Name = "Euston", _
                .FareZone = "Fare zone 1", _
                .GroupBy = "e" _
            })
            source.Add(New Victoria() With { _
                .Name = "Finsbury Park", _
                .FareZone = "Fare zone 2", _
                .GroupBy = "f" _
            })
            source.Add(New Victoria() With { _
                .Name = "Green Park", _
                .FareZone = "Fare zone 1", _
                .GroupBy = "g" _
            })
            source.Add(New Victoria() With { _
                .Name = "Highbury & Islington", _
                .FareZone = "Fare zone 2", _
                .GroupBy = "h" _
            })
            source.Add(New Victoria() With { _
                .Name = "King's Cross St. Pancras", _
                .FareZone = "Fare zone 1", _
                .GroupBy = "k" _
            })
            source.Add(New Victoria() With { _
                .Name = "Oxford Circus", _
                .FareZone = "Fare zone 1", _
                .GroupBy = "o" _
            })
            source.Add(New Victoria() With { _
                .Name = "Pimlico", _
                .FareZone = "Fare zone 1", _
                .GroupBy = "p" _
            })
            source.Add(New Victoria() With { _
                .Name = "Seven Sisters", _
                .FareZone = "Fare zone 3", _
                .GroupBy = "s" _
            })
            source.Add(New Victoria() With { _
                .Name = "Stockwell", _
                .FareZone = "Fare zone 2", _
                .GroupBy = "s" _
            })
            source.Add(New Victoria() With { _
                .Name = "Tottenham Hale", _
                .FareZone = "Fare zone 3", _
                .GroupBy = "t" _
            })
            source.Add(New Victoria() With { _
                .Name = "Vauxhall", _
                .FareZone = "Fare zones 1 and 2", _
                .GroupBy = "v" _
            })
            source.Add(New Victoria() With { _
                .Name = "Victoria", _
                .FareZone = "Fare zone 1", _
                .GroupBy = "v" _
            })
            source.Add(New Victoria() With { _
                .Name = "Walthamstow Central", _
                .FareZone = "Fare zone 3", _
                .GroupBy = "w" _
            })
            source.Add(New Victoria() With { _
                .Name = "Warren Street", _
                .FareZone = "Fare zone 1", _
                .GroupBy = "w" _
            })
    
            Dim MygroupBy = From jumpdemo In source _
                          Group jumpdemo By jumpdemo.GroupBy Into c = Group _
                          Order By GroupBy _
                          Select New  _
                          Group(Of Victoria)(GroupBy, c)
    
            Me.citiesListGroups.ItemsSource = MygroupBy
        End Sub
    End Class
    
    
    Public Class Group(Of T)
        Implements IEnumerable(Of T)
        Public Sub New(name As String, items As IEnumerable(Of T))
            Me.Title = name
            Me.Items = New List(Of T)(items)
        End Sub
        Public Overrides Function Equals(obj As Object) As Boolean
            Dim that As Group(Of T) = TryCast(obj, Group(Of T))
            Return (that IsNot Nothing) AndAlso (Me.Title.Equals(that.Title))
        End Function
        Public Property Title() As String
            Get
                Return m_Title
            End Get
            Set(value As String)
                m_Title = Value
            End Set
        End Property
        Private m_Title As String
        Public Property Items() As IList(Of T)
            Get
                Return m_Items
            End Get
            Set(value As IList(Of T))
                m_Items = Value
            End Set
        End Property
        Private m_Items As IList(Of T)
        Public Function GetEnumerator() As IEnumerator(Of T) Implements IEnumerable(Of T).GetEnumerator
            Return Me.Items.GetEnumerator()
        End Function
        Private Function System_Collections_IEnumerable_GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
            Return Me.Items.GetEnumerator()
        End Function
    End Class
    
    
    Public Class Victoria
        Public Property Name() As String
            Get
                Return m_Name
            End Get
            Set(value As String)
                m_Name = value
            End Set
        End Property
        Private m_Name As String
    
        Public Property FareZone() As String
            Get
                Return m_FareZone
            End Get
            Set(value As String)
                m_FareZone = value
            End Set
        End Property
        Private m_FareZone As String
    
        Public Property GroupBy() As String
            Get
                Return m_GroupBy
            End Get
            Set(value As String)
                m_GroupBy = value
            End Set
        End Property
        Private m_GroupBy As String
    End Class
    

    LLS No. 2

    Imports System.Linq
    Imports Microsoft.Phone.Controls
    
    Partial Public Class Bakerloo_line
        Inherits PhoneApplicationPage
    
        Public Sub New()
            InitializeComponent()
            Dim source As New List(Of Bakerloo)()
            source.Add(New Bakerloo() With { _
                .Name = "Blackhorse Road", _
                .FareZone = "Fare zone 3", _
                .GroupBy = "b" _
            })
            source.Add(New Bakerloo() With { _
                .Name = "Brixton", _
                .FareZone = "Fare zone 2", _
                .GroupBy = "b" _
            })
            source.Add(New Bakerloo() With { _
                .Name = "Euston", _
                .FareZone = "Fare zone 1", _
                .GroupBy = "e" _
            })
            source.Add(New Bakerloo() With { _
                .Name = "Finsbury Park", _
                .FareZone = "Fare zone 2", _
                .GroupBy = "f" _
            })
            source.Add(New Bakerloo() With { _
                .Name = "Green Park", _
                .FareZone = "Fare zone 1", _
                .GroupBy = "g" _
            })
            source.Add(New Bakerloo() With { _
                .Name = "Highbury & Islington", _
                .FareZone = "Fare zone 2", _
                .GroupBy = "h" _
            })
            source.Add(New Bakerloo() With { _
                .Name = "King's Cross St. Pancras", _
                .FareZone = "Fare zone 1", _
                .GroupBy = "k" _
            })
            source.Add(New Bakerloo() With { _
                .Name = "Oxford Circus", _
                .FareZone = "Fare zone 1", _
                .GroupBy = "o" _
            })
            source.Add(New Bakerloo() With { _
                .Name = "Pimlico", _
                .FareZone = "Fare zone 1", _
                .GroupBy = "p" _
            })
            source.Add(New Bakerloo() With { _
                .Name = "Seven Sisters", _
                .FareZone = "Fare zone 3", _
                .GroupBy = "s" _
            })
            source.Add(New Bakerloo() With { _
                .Name = "Stockwell", _
                .FareZone = "Fare zone 2", _
                .GroupBy = "s" _
            })
            source.Add(New Bakerloo() With { _
                .Name = "Tottenham Hale", _
                .FareZone = "Fare zone 3", _
                .GroupBy = "t" _
            })
            source.Add(New Bakerloo() With { _
                .Name = "Vauxhall", _
                .FareZone = "Fare zones 1 and 2", _
                .GroupBy = "v" _
            })
            source.Add(New Bakerloo() With { _
                .Name = "Victoria", _
                .FareZone = "Fare zone 1", _
                .GroupBy = "v" _
            })
            source.Add(New Bakerloo() With { _
                .Name = "Walthamstow Central", _
                .FareZone = "Fare zone 3", _
                .GroupBy = "w" _
            })
            source.Add(New Bakerloo() With { _
                .Name = "Warren Street", _
                .FareZone = "Fare zone 1", _
                .GroupBy = "w" _
            })
    
            Dim MygroupBy = From jumpdemo In source _
                          Group jumpdemo By jumpdemo.GroupBy Into c = Group _
                          Order By GroupBy _
                          Select New  _
                          Group(Of Bakerloo)(GroupBy, c)
    
            Me.citiesListGroups.ItemsSource = MygroupBy
        End Sub
    End Class
    
    
    Public Class Group(Of Bakerloo)
        Implements IEnumerable(Of Bakerloo)
        Public Sub New(name As String, items As IEnumerable(Of Bakerloo))
            Me.Title = name
            Me.Items = New List(Of Bakerloo)(items)
        End Sub
        Public Overrides Function Equals(obj As Object) As Boolean
            Dim that As Group(Of Bakerloo) = TryCast(obj, Group(Of Bakerloo))
            Return (that IsNot Nothing) AndAlso (Me.Title.Equals(that.Title))
        End Function
        Public Property Title() As String
            Get
                Return m_Title
            End Get
            Set(value As String)
                m_Title = value
            End Set
        End Property
        Private m_Title As String
        Public Property Items() As IList(Of Bakerloo)
            Get
                Return m_Items
            End Get
            Set(value As IList(Of Bakerloo))
                m_Items = value
            End Set
        End Property
        Private m_Items As IList(Of Bakerloo)
        Public Function GetEnumerator() As IEnumerator(Of Bakerloo) Implements IEnumerable(Of Bakerloo).GetEnumerator
            Return Me.Items.GetEnumerator()
        End Function
        Private Function System_Collections_IEnumerable_GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
            Return Me.Items.GetEnumerator()
        End Function
    End Class
    
    
    Public Class Bakerloo
        Public Property Name() As String
            Get
                Return m_Name
            End Get
            Set(value As String)
                m_Name = value
            End Set
        End Property
        Private m_Name As String
    
        Public Property FareZone() As String
            Get
                Return m_FareZone
            End Get
            Set(value As String)
                m_FareZone = value
            End Set
        End Property
        Private m_FareZone As String
    
        Public Property GroupBy() As String
            Get
                Return m_GroupBy
            End Get
            Set(value As String)
                m_GroupBy = value
            End Set
        End Property
        Private m_GroupBy As String
    End Class
    Sunday, September 01, 2013 9:04 AM
  • Try something like this

    Sub Main()
            Dim source As New List(Of JumpDemo)()
            For alphaCount = 0 To 25
                Dim Letter As String = Chr(Asc("A") + alphaCount)
                source.Add(New JumpDemo() With { _
                .Name = Letter, _
                .GroupBy = Letter _
            })
            Next
            Dim MygroupBy = From jumpdemo In source _
                   Group jumpdemo By jumpdemo.GroupBy Into c = Group _
                   Order By GroupBy _
                   Select New  _
                   Group(Of JumpDemo)(GroupBy, c)
            For Each item In MygroupBy
                If item.Count = 0 Then
                    'add code to gray control here 
                End If
            Next item
        End Sub


    jdweng

    Sunday, September 01, 2013 9:18 AM
  •  You did post an error message.

    jdweng

    Sunday, September 01, 2013 10:02 AM
  • I've got lost again. Where in the .vb page does this go?
    Sunday, September 01, 2013 5:49 PM
  • In the constructor in place of the code you now have that creates the buttons.  I should of put in in the Sub New() instead of Sub Main().  You didn't post the last error you were getting.

    jdweng

    Sunday, September 01, 2013 8:19 PM
  • What did you mean by: For Each item In MygroupBy If item.Count = 0 Then 'add code to gray control here And in the code you suggested, why is InitializeComponent not in the code?
    Monday, September 02, 2013 11:00 AM
  • You are correct that yu need intiailizecomponents.  I was just showing how to enumerate through the letters of the alphabet and add buttons.  I didn't care where the code was placed in the project.

    I wasn't sure how to gray ou tthe button.  I think all you have to do is set enable to false like this

            For Each item In MygroupBy
                If item.Count = 0 Then
                    'add code to disable control here
                    item.Enable = false
                End If
            Next item


    jdweng

    Monday, September 02, 2013 11:15 AM
  • OK followed that code suggestion but these errors have appeared and have suggested some options but I don't know what to do:

    Monday, September 02, 2013 2:06 PM
  • I can't setup a Phone applkcation on my PC, but I now understand what is happening.

    In the line below Me is the view (a form) with  citiesListGroups being a control with the leters in the alphabet each being a row inside the control.

    Me.citiesListGroups.ItemsSource = MygroupBy

    Below is a webpage showing the methods.

    http://msdn.microsoft.com/en-us/library/windowsphone/develop/microsoft.phone.controls.jumplistitembackgroundconverter(v=vs.105).aspx

    I really can't help you with this.  button enble is shown on the webpage below but I can't give you the exact instructions to use in your application

    http://nikovrdoljak.wordpress.com/category/windows-phone/



    jdweng

    Monday, September 02, 2013 4:19 PM
  • I'm not sure if you answered my other question about implementing another LongListSelector within my project.
    Tuesday, September 03, 2013 10:05 AM
  • You have two classes named Group in the same namespace

         1) Public Class Group(Of T)

         2) Public Class Group(Of Bakerloo)

    Change the name of one of them to something else.


    jdweng

    Tuesday, September 03, 2013 10:42 AM
  • Oh OK. Would e.g.

    1) Public Class Food(Of T)

    2) Public Class Drink(Of T)

    be acceptable?

    Also do you know what the "(Of T)" section means?

    Tuesday, September 03, 2013 1:50 PM
  • As long as the two classes had diffferent name anything wopuld be acceptable.  (Of T) allow the class to except any type.  So in theory if both class were exactly the same, you could use (Of T) and pass BakerLoo instead of T.

    jdweng

    Tuesday, September 03, 2013 3:10 PM
  • OK cool. Do you know anything about implementing animation for the GroupHeader of a LongListSelector? I.e. when the users tap on a GroupHeader letter, the available letter categories animate and when a letter is tapped the categories disappear and the list performs an animation to scroll to the selected letter group?
    Tuesday, September 03, 2013 8:29 PM