LongListSelector in Windows Phone 8 Is Always Empty
I am trying to move my app to Windows Phone 8 and I am using the newly built LongListSelector, however no matter what I do I am unable to get any items to appear beneath each group header item. I am trying to display an alphabetically grouped list of names of Airlines. I can see each of the group headers, but the items are always empty.
I’ve used a custom binding converter to see if there was something wrong in the XAML binding, but the converter doesn’t get called at all, which makes me think that something is happening to the LongListSelector’s ItemSource property.
This code worked perfectly in Windows Phone 7, however something has broken during the SDK update. For the life of me I can’t find the answer. Help!!
This is the code I used to assign to the ItemsSource class:
var airlinesByName = from airline in App.ViewModel.AirlineName orderby airline.ToLower() group airline by airline.ToLower()[0] into c orderby c.Key select new Group<string>(c.Key, c); this.lls_Selector.ItemsSource = airlinesByName;
I use the following extension of IEnumerable<T> to group the items above:
public class Group<T> : IEnumerable<T>
{
public Group(char name, IEnumerable<T> items)
{
this.Letter = name;
this.Items = new List<T>(items);
}
public override bool Equals(object obj)
{
Group<T> that = obj as Group<T>;
return (that != null) && (this.Letter.Equals(that.Letter));
}
public char Letter
{
get;
set;
}
public IList<T> Items
{
get;
set;
}
#region IEnumerable<T> Members
public IEnumerator<T> GetEnumerator()
{
return this.Items.GetEnumerator();
}
#endregion
#region IEnumerable Members
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return this.Items.GetEnumerator();
}
#endregion
}







