The answer you're looking for is a ReorderListBox developed by Jason Ginkreo.
I am going to demonstrate its quick implementation, but if you want a full demo, download the source from CodePlex here .
First install the control from Nuget:
- Tools →> Library Package Manager →> Managing NuGet packages to solve ...
- Locate the ReorderListBox and install the file created by Jason Ginchereau
Then in the XAML of the start page of your application (i.e. MainPage.xaml ) copy and paste the highlighted assembly link into the phone: PhoneApplicationPage tag to the top, where other assembly links are located.
xmlns:rlb="clr-namespace:ReorderListBox;assembly=ReorderListBox"
Then move this to your XAML page
<rlb:ReorderListBox x:Name="reorderListBox" Grid.Row="2" Margin="12,0,12,12" IsReorderEnabled="True"> <rlb:ReorderListBox.ItemTemplate> <DataTemplate> <TextBlock Margin="12,4,12,4" FontSize="36" Text="{Binding}" /> </DataTemplate> </rlb:ReorderListBox.ItemTemplate> </rlb:ReorderListBox>
Finally, in your code lag (i.e. MainPage.xaml.cs ) you want to define an ObservableCollection as your data list and assign it to reorderListBox.ItemsSource . You can also save the state of the list after it is accessed the next time the application is opened. Here is an example:
public partial class MainPage : PhoneApplicationPage { public ObservableCollection<string> SampleDataList { get; set; } // Constructor public MainPage() { InitializeComponent(); if (IsolatedStorageSettings.ApplicationSettings.Contains("SampleDataList")) { SampleDataList = IsolatedStorageSettings.ApplicationSettings["SampleDataList"] as ObservableCollection<string>; } else { SampleDataList = new ObservableCollection<string>(); SampleDataList.Add("Zero"); SampleDataList.Add("One"); SampleDataList.Add("Two"); SampleDataList.Add("Three"); SampleDataList.Add("Four"); SampleDataList.Add("Five"); SampleDataList.Add("Six"); SampleDataList.Add("Seven"); SampleDataList.Add("Eight"); SampleDataList.Add("Nine"); SampleDataList.Add("Ten"); SampleDataList.Add("Eleven"); SampleDataList.Add("Twelve"); SampleDataList.Add("Thirteen"); SampleDataList.Add("Fourteen"); } reorderListBox.ItemsSource = SampleDataList; } protected override void OnNavigatedFrom(NavigationEventArgs e) { base.OnNavigatedFrom(e); IsolatedStorageSettings.ApplicationSettings["SampleDataList"] = SampleDataList; IsolatedStorageSettings.ApplicationSettings.Save(); } }
source share