Longlistselector on Windows Phone 8

Asked

Viewed 125 times

1

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

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

enter image description here

2 answers

2


Here’s a link demonstrating how to migrate Longlistselector from Windows Phone 8 to Windows Phone 8.1, it works for you because it shows you how it works in version 8.0.

http://www.visuallylocated.com/post/2014/04/28/Migrating-from-the-LongListSelector-to-the-ListView-in-Windows-Phone-XAML-Apps.aspx

Already in the part of passing parameters from one page to the other, you do the following: You add the event SelectionChanged within the ListBox populated with contacts. Then on the page you want to show the 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 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 method OnNavigatedTo you fill the screen components

//DetalhesContato.xaml.cs    
protected override void OnNavigatedTo(NavigationEventArgs e)
{
    textBlockNome.Text = contato.Nome;
    textBlockTelefone.Text = contato.Telefone;
    //etc
}

Already in the 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;
}

0

Very simple!

  1. Create a class Pessoa, that has all layout attributes (i.e. Name, E-mail, Phones, etc, etc., etc);
  2. I believed a ListBox in your XAML file;
  3. Refer to a Binding for your class Person;
  4. No . Cs, make yours ListBox carry a List of Pessoa using the method meuListBox.itemSource = minhasPessoas;
  • By then I knew Felipe! My problem is that it will have to be a Longlistselector and by clicking on the "block" will move to the next screen with more data from the "person".

  • But thank you so much for the start! It’s already very helpful!

  • Right, but what’s the difference then? The click event you can use onHold for example. Take a look here: https://msdn.microsoft.com/en-us/library/microsoft.phone.controls.longlistselector(v=vs.105). aspx

  • But I could do it this way in what way? Can you indicate me some step-by-step? In other words, leave practically the same layout.

  • up try to solve

Browser other questions tagged

You are not signed in. Login or sign up in order to post.