如何在其他page.xaml中获取listview值

时间:2015-11-01 21:58:42

标签: c# listview windows-phone-8.1

我有一个列表视图,我想在点击时传递该值。

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);
}

我正在使用此命令:

Frame.Navigate(typeof(hinoDetail), listaHinos);

但是当我点击并在其他页面中打开时,我不知道如何获得listaHinos值。

  

另一页在下面。

public hinoDetail()
    {
        this.InitializeComponent();

    }

    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        var result = e.Parameter as List<hinos>;
    }

    public async void mostraHino()
    {

    }

1 个答案:

答案 0 :(得分:0)

我假设上面的代码来自您要导航到的屏幕?如果是这样的话:

public hinoDetail()
{
    this.InitializeComponent();

}

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    hinos result = (e.Parameter as List<hinos>).FirstOrDefault(); //gets the first one only
   textBlock.Text = result.nameHino

}

public async void mostraHino()
{

}