GridView ItemClick 导航到另一个页面并显示有关所点击项目的详细信息 Windows 应用商店

GridView ItemClick navigate to another page and show details about the clicked item Windows store app

我有一个 GridView 项目来自人员列表,我如何在下一页显示点击项目的详细信息?

我在主页上使用了这段代码

Private Sub itemGridView_ItemClick(sender As Object, e As ItemClickEventArgs) Handles itemGridView.ItemClick
    Me.Frame.Navigate(GetType(BlankPage1), e.ClickedItem)
End Sub

我在下一页中使用了它

Private Sub NavigationHelper_LoadState(sender As Object, e As Common.LoadStateEventArgs)
    Dim n As Person = TryCast(e.NavigationParameter, Person)
    txt.Text = n.Name
End Sub

我通过更改代码修复了它

Private Sub itemGridView_ItemClick(sender As Object, e As ItemClickEventArgs) Handles itemGridView.ItemClick
    Dim person As Person = DirectCast(e.ClickedItem, Person)
    Me.Frame.Navigate(GetType(BlankPage1), person)
End Sub

在下一页

Private Sub NavigationHelper_LoadState(sender As Object, e As Common.LoadStateEventArgs)
    Dim person As Person = DirectCast(e.NavigationParameter, Person)
    Me.DefaultViewModel("Details") = person
End Sub

并且在我的 xaml 文件中添加了这个

DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"