public class Book{
public string Title { get; set; }
public string BookCover{ get; set; }
}
public class Bookmanager
{
public static List<Book> GetBook()
{
var BookID= new List<Book>();
BookID.Add(new Book{ Title = "fruits", BookCover= "Assets/1.jpg" });
BookID.Add(new Book{ Title = "food", BookCover= "Assets/2.jpeg" });
return BookID;
}
}
<GridView ItemsSource="{x:Bind BookID}" Margin="0,0,49,121"
ItemClick="GridView_ItemClick" IsItemClickEnabled="True" >
<GridView.ItemTemplate>
<DataTemplate x:DataType="local:Book">
<Grid Height="186" Width="155">
<Image Stretch="Fill" Source="{x:Bind <GridView ItemsSource="{x:Bind BookCover}" Margin="0,0,49,121"
ItemClick="GridView_ItemClick" IsItemClickEnabled="True" >
</grid>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
这是我在XAML.cs中的源代码我已经编写了导航到我的图像的代码所以我应该在我的ItemPage中编写什么代码来检索我的BookCover图像。请帮助我#39在这里新来的!
private void GridView_ItemClick(object sender, ItemClickEventArgs e)
{
var Mybooks= ((Book)e.ClickedItem).BookCover;
this.Frame.Navigate(typeof(ItemPage), Mybooks);
}
答案 0 :(得分:0)
Page类已经实现了接口IPageOverrides。 所以你只需要在你的ItemPage中覆盖它,如下所示:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
////this.Frame.Navigate(typeof(ItemPage), Mybooks);
//e.Parameter is Mybooks.
}