Displaying data in flat list in Windows Phone 8 LongListSelector Control

Published on October 29, 2013 by abundantcode

Filed under Windows Phone

Last modified October 29, 2013

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 0 (0 votes)

This article have been viewed 4377 times

Below is a sample code snippet demonstrating the display of the flat list in the Windows Phone 8 LongListSelector Control.

Displaying data in flat list in Windows Phone 8 LongListSelector Control

LongListSelector Declaration

<phone:LongListSelector Name="lstWebsites" HorizontalAlignment="Left" VerticalAlignment="Top" LayoutMode="List" IsGroupingEnabled="False" Width="446">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Name}" />
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>

Model

public class WebsiteName
{
  public string Name
  {
   get;
   set;
  }
  public int ID
  {
   get;
   set;
  }
  }

Data

ObservableCollection<WebsiteName> websites = new ObservableCollection<WebsiteName>();
websites.Add(new WebsiteName { Name = "Abundantcode.com", ID = 1 });
websites.Add(new WebsiteName { Name = "http://Abundantcode", ID = 2 });
websites.Add(new WebsiteName { Name = "www.Abundantcode.com", ID = 3 });
lstWebsites.ItemsSource = websites;

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

1 Comment

  1. VItaliy

    Thank you! I was scoring the web for a simple explanation of longlistselectors and flat list. This is as simple as it gets.

    March 12, 2014 - 10:49 am – Reply

Leave a Comment


x

You might be Interested in these Posts

How to delete user account from command line in Windows 10 ?

You can delete a user account from command line in Windows 10 using the net user command and specify...

How to add new user account from command line in Windows 10 ?

You can add a new user account in Windows 10 using command prompt using the net user command and pas...

How to open display settings from command line in Windows 10 ?

The display properties can be found in the settings app in Windows 10 which lets the users to config...