我如何将page1.html paeg从mainpage.xaml带到secondpage.xamm并在webContr
本文关键字:带到 xaml secondpage xamm webContr 并在 mainpage page1 paeg html | 更新日期: 2023-09-27 18:30:12
我想显示一些来自隔离存储的.html文件,这些文件位于(主文件夹->subFolder1->SubFolder2->page1.html).
我如何将page1.html页面从mainpage.xaml带到secondpage.xaml并在webControl浏览器上显示?
简而言之:
我的secondPage.xaml包含一个web浏览器控件,因此我想显示page1.html来自mainpage.xaml,我的页面位于上面的存储位置。
所以我终于有了一个合适的答案。我的要求是从等插存储表单Mainpage.xaml中获取值,并显示在SecondPage.xaml的web浏览器控件上。这就是我想要的从ListBox控件中选择的图像,该控件设置在MainPage.xaml.上
因此,下面的代码和我提到的内联文档一起制作了这个场景。
**//MainPage.xaml.**
private async void imgBookImage_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
//It is the way to take the id from the listView if you are showing your listView through Wrapper using ObservableCollection.
myWrapper bookName = (myWrapper)this.listCloudBooks.SelectedItem;
IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
string dir = "/MainFolder/SubFolder/" + bookName.Id;
if (isf.DirectoryExists(dir))
{
NavigationService.Navigate(new Uri("/MainPage.xaml?selectedItem=" +bookName.Id, UriKind.Relative));//bookName.Id fetching Id of book and through bookid we will get the id on our destination page and will show the data.
}
else
{
//In this method i am creating folder of bookId and storing into the destination folder in my isolated storage. I am not showing the code of this method because i am answering of this question only.
DownloadBooks(bookName);
}
}
//SecondPage.xaml
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
string selectedBookId = "";//Set this variable globally.
position = 1;
IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
string dir = "/MainFolder/SubFolder/" + selectedBookId;
string concatBookJson = string.Concat(dir, "/pageRecords.json");//Taking pageRecords.json, my this file have records of my *.html pages so it is showing from isolateStorage
if (isf.FileExists(concatBookJson))
{
CurrentBook = GetBookContents(concatBookJson);//Returning the Json Deserialize data from the isolated storage.
txtBookName.Text = CurrentBook.Title;//I have title property you can access all properties of your wrapper class (myWrapper).
}
}
您应该使用OnNavigated Event从MainPage.xaml获取值,我的要求不同,所以我在PhoneApplication_Loaded事件中显示了这一点