I'm trying to make my longlistselector to navigate to different pages, according to the option chosen. For example A navigates to a.xaml B navigates to b.xaml, same with C D E etc.
Xaml
<phone:LongListSelector
SelectionChanged="SelectionChanged"
x:Name="AddrBook"
JumpListStyle="{StaticResource AddrBookJumpListStyle}"
Background="Transparent"
GroupHeaderTemplate="{StaticResource AddrBookGroupHeaderTemplate}"
ItemTemplate="{StaticResource AddrBookItemTemplate}"
LayoutMode="List"
IsGroupingEnabled="true"
HideEmptyGroups ="true" Foreground="Black" Margin="0,20,0,0" FontSize="32"/>
Code Behind:
{
public partial class ASectionPopSpanish : PhoneApplicationPage
{
public ASectionPopSpanish()
{
InitializeComponent();
List<AddressBook> source = new List<AddressBook>();
source.Add(new AddressBook("Joe", "Davidbisbal"));
source.Add(new AddressBook("AdJoe", "Davidbisbal"));
source.Add(new AddressBook("BJoe", "Davidbisbal"));
source.Add(new AddressBook("VJoe", "Davidbisbal"));
source.Add(new AddressBook("VJoe", "Davidbisbal"));
source.Add(new AddressBook("CJoe", "Davidbisbal"));
source.Add(new AddressBook("EJoe", "Davidbisbal"));
source.Add(new AddressBook("Joe", "Davidbisbal"));
List<AlphaKeyGroup<AddressBook>> DataSource = AlphaKeyGroup<AddressBook>.CreateGroups(source,
System.Threading.Thread.CurrentThread.CurrentUICulture,
(AddressBook s) => { return s.LastName; }, true);
AddrBook.ItemsSource = DataSource;
}
public class AddressBook
{
public string LastName
{
get;
set;
}
public string SectionPage
{
get;
set;
}
public AddressBook(string lastname, string sectionpage)
{
this.LastName = lastname;
this.SectionPage = sectionpage;
}
}
private void SelectionChanged(object sender, SelectionChangedEventArgs e)
{
AddressBook selectedAddress = (AddressBook)AddrBook.SelectedItem;
if (AddrBook.SelectedItem == null)
return;
NavigationService.Navigate(new Uri(AddressBook.SelectedItem.SectionPage & ".xaml", UriKind.Relative));
AddrBook.SelectedItem = null;
}
}
}
I understand I need to implement a selectionchanged, but can't figure out how to do it, can someone give me a hand please?