How to pick up values from a listview on another.xaml page

Asked

Viewed 119 times

0

I have this class that fills the values in 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 intention 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 passed wrong, I would like to access the values of the listview selected on the other page.

1 answer

0

You want to access the selected item, right? As of the current mode, you are sending all the ListView to the next page. Instead, send only the selected object using the 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);
}

Browser other questions tagged

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