我有一个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
答案 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}}"