LongListSelector on Windows Phone 8

1

I would like to make a screen with a LongListSelector this way, taking results from a webservice of mine and mounting in that style.

How could I develop this? I am a layman in this part of XAML, is it possible to indicate the basic steps to build an interface like the one in the figure below?

    
asked by anonymous 23.01.2015 / 18:12

2 answers

2

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;
}
    
30.01.2015 / 02:18
0

Very simple!

  • Create a class Pessoa , which has all the layout attributes (i.e. Name, Email, Telephones, etc, etc);
  • I created a ListBox in your XAML file;
  • Refer a Binding to your Person class;
  • In .cs, have your ListBox load List Pessoa using the meuListBox.itemSource = minhasPessoas method;
  • 23.01.2015 / 18:35