Here is a link demonstrating how to migrate LongListSelector from Windows Phone 8 to Windows Phone 8.1, it works for you because it shows how it works in version 8.0.
link
Already in the part of passing parameters from one page to the other, you do the following: You add the SelectionChanged
event within the ListBox
populated with the contacts. Then on the page you want to show details, do the following: (in the example I named DetalhesContato.xaml
)
First you need to create a property of the type of class you are using for the contacts, in the example I use Contato
, leave it as global.
//Tanto na MainPage.xaml.cs quanto na DetalhesContato.xaml.cs
//crie a propriedade
public Contato contato { get; set; }
So in the OnNavigatedTo
method you fill in the screen components
//DetalhesContato.xaml.cs
protected override void OnNavigatedTo(NavigationEventArgs e)
{
textBlockNome.Text = contato.Nome;
textBlockTelefone.Text = contato.Telefone;
//etc
}
In MainPage.xaml.cs
you treat the event SelectionChanged
//Mainpage.xaml.cs
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
Contato c = (sender as ListBox).SelectedItem as Contato;
//Salva o contato na propriedade da classe, para ser enviado
this.contato = c;
this.NavigationService.Navigate(
new Uri("/DetalhesContato.xaml", UriKind.Relative));
}
To pass the contact object to the next page, use the method OnNavigatedFrom
//Mainpage.xaml.cs
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
//Recupera a próxima página
DetalhesContato page = e.Content as DetalhesContato
//é preciso que seja o mesmo nome da propriedade que vc criou no DetalhesContato.xaml.cs
page.contato = this.contato;
}