How to get values from a listview on another page.xaml

0
  

I have this class that fills the values in the listview.

    public Lista()
{
    this.InitializeComponent();
    carregaLista();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
}
public async void carregaLista()
{

    var local = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "hinos.sqlite");
    SQLiteAsyncConnection con = new SQLiteAsyncConnection(local, SQLiteOpenFlags.Create | SQLiteOpenFlags.ReadWrite);

    listaHinos.ItemsSource = await con.Table<hinos>().ToListAsync();
}

public void listaHinos_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    Frame.Navigate(typeof(hinoDetail), listaHinos);
}
  

The intent is to click on the item and detail it on the other page

    public void listaHinos_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    Frame.Navigate(typeof(hinoDetail), listaHinos);
}
  

The code is working, I do not know if I went wrong, I would like to access the values of the selected listview on the other page.

    
asked by anonymous 01.11.2015 / 23:28

1 answer

0

You want to access the selected item, right? In current mode, you are sending all ListView to the next page. Instead, just send the selected object using SelectedItem

public void listaHinos_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    //estou considerando que "hinos" seja sua classe
    hinos hino = (hinos)listaHinos.SelectedItem;
    Frame.Navigate(typeof(hinoDetail), hino);
}
    
17.03.2016 / 22:16