I want to bind list of objects to toolkit LongListSelector Windows Phone 7 as what i do in Windows Phone 8. Anyone could tell my where's wrong?
Nothing show in the LongListSelector
XAML
<toolkit:LongListSelector Name="MyLLS">
<toolkit:LongListSelector.ItemTemplate>
<DataTemplate>
<Grid Background="#4A6EA9" Height="60" Margin="2">
<TextBlock Text="{Binding Title}"/>
</Grid>
</DataTemplate>
</toolkit:LongListSelector.ItemTemplate>
</toolkit:LongListSelector>
Class
public class NewsItem
{
public string Link { get; set; }
public string Title { get; set; }
}
MainPage()
{
// something already
MyLLS.ItemsSource = new List<NewsItem> {
new NewsItem { Link = "http://google.com", Title= "Google Search" }
};
}
I've not played much with WP7 ToolKit but I've managed to display list like this:
In XAML - removed Grid and added isFlatList:
<toolkit:LongListSelector Name="MyLLS" IsFlatList="True">
<toolkit:LongListSelector.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Title}"/>
</DataTemplate>
</toolkit:LongListSelector.ItemTemplate>
</toolkit:LongListSelector>
In code behind:
ObservableCollection<NewsItem> myList = new ObservableCollection<NewsItem>();
MainPage()
{
InitializeComponent();
// something already
MyLLS.ItemsSource = myList;
myList.Add(new NewsItem { Link = "http://google.com", Title= "Google Search" });
}
I haven't got much time to play with the code above, but maybe it will help. I would advise to read some tutorials - WP7 LongListSelector in depth Part1, WP7 LongListSelector in depth Part2 and probably more.