0
我有類列表視圖,列表視圖是從源碼得到的ListView值時,在其他page.xaml點擊項目
public Lista()
{
this.InitializeComponent();
carregaLista();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
}
private void AppBarButton_Click(object sender, RoutedEventArgs e)
{
Frame.Navigate(typeof(Home));
}
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.ItemsSource); // passing listview to hinoDetail Class
}
獲取值我傳遞列表視圖hinoDetail類下面
public hinoDetail()
{
this.InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// List<hinos> result = e.Parameter as List<hinos>;
hinos result = (e.Parameter as List<hinos>).FirstOrDefault(); // get first line only
nomeHinoDetail.Text = result.numHino + " " + result.nomeHino;
textBlock.Text = result.letraHino;
}
private void AppBarButton_Click(object sender, RoutedEventArgs e)
{
Frame.Navigate(typeof(Lista));
}
的hinoDet所有的類只是從listview中獲取第一個值,因爲(FirstOrDefault()但我不知道我需要什麼方法。),我想獲得我點擊的值。 (如果我在第一次點擊 - >獲得第一,如果我在第二次 - >獲得第二個值).....