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

时间:2015-01-25 02:53:01

标签: c# vb.net xaml windows-store-apps

我有一个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

1 个答案:

答案 0 :(得分:0)

我通过更改我的代码来修复它

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}}"