0

我想显示来自隔离存储的一些 .html 文件,这些文件位于 (MainFolder -> subFolder1 -> SubFolder2 -> page1.html)中。

如何将 page1.html 页面从 mainpage.xaml 带到 secondpage.xaml 并在 webControl 浏览器上显示?

简单来说:

我的 secondPage.xaml 包含一个 Web 浏览器控件,因此我想从 mainpage.xaml 显示 page1.html,我的页面位于上述存储位置。

4

1 回答 1

0

所以最后我对我的问题有一个正确的答案。我的要求是从隔离存储表单 Mainpage.xaml 中获取值并显示在 SecondPage.xaml 的 Web 浏览器控件上。这就是我想要从在 MainPage.xaml 上设置的 ListBox 控件中选择图像的所有内容。

因此,代码与我提到的用于制作场景的内联文档一起跟随。

**//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 事件从 MainPage.xaml 中获取值,我的要求不同,所以我在 PhoneApplciation_Loaded 事件中显示。

于 2013-09-05T05:11:37.440 回答