pdfnet - re-opening a pdf after returning to a page with NavigationCacheMode.Enabled

I have 2 pages on a windows store app project.

First page displays a pdf file in a small part of the page, and i have a button that when i press i open the other page with the pdf loaded in full screen.

On page1 i have this on its constructor:

this.NavigationCacheMode = NavigationCacheMode.Enabled;

Im using PDFtron to view and edit the pdf files. on Page1 OnNavigatedTo method i have this

                    pdftron.PDFNet.Initialize();
                    MyPDFViewCtrl = new pdftron.PDF.PDFViewCtrl();
                    PDFViewBorder.Child = MyPDFViewCtrl;
                    MyToolManager = new pdftron.PDF.Tools.ToolManager(MyPDFViewCtrl);
                    pdfViewer.Visibility = Visibility.Visible;

and this on xaml:

<Grid x:Name="pdfViewer" Background="Blue" Canvas.ZIndex="111" Visibility="Visible" >
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>

                        <Border x:Name="PDFViewBorder" Background="Green" Grid.Row="0"/>

                    </Grid>

to open the pdf i have something like this:

folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(Constants.DataDirectory, CreationCollisionOption.OpenIfExists);
       file = await folder.CreateFileAsync(document.fileName, CreationCollisionOption.OpenIfExists);
       docpdf = new PDFDoc(file);
       MyPDFViewCtrl.SetDoc(docpdf);
       Debug.WriteLine(MyPDFViewCtrl.GetPageCount());

So the problem is this: When i enter page1, it displays the pdf correctly, i then press the button and navigate to page2 where it shows the file in fullscreen correctly, when i go back to previous page the file seems to be loaded correctly to the docpdf variable (it shows the correct number of pages on the Debug.WriteLine) , but it doesn't show on the MyPDFViewCtrl, i get a empty Green Square.

Do i need to enable any sort of parameter?

just adding a bit more info

on my second page i have this variable declared

ViewModels.MainPageViewModel _ViewModel;

and this on its constructor

_ViewModel = new ViewModels.MainPageViewModel();
this.DataContext = _ViewModel;

this is the code for the MainPageViewModel ( taken from one of your samples )
http://paste2.org/LcXegZyG

and when i go back to page1 i have this on my GoBack function

_ViewModel.Close();
Frame.GoBack();

heres a picture of when i pick a file on page1 the first time i enter
http://postimg.org/image/vsd63hbi9/

and another when i do the same thing after comming from the page2
http://postimg.org/image/rr0obk8ld/

Hi Ricardo,

Would it be possible to send us your sample? Figuring this out would require us to reproduce the problem, and that will be hard to do with just a description.

Best Regards,
Tomas Hofmann

I have figured it out, it was a error from my part.

terça-feira, 8 de Dezembro de 2015 às 16:37:02 UTC, Ricardo Silva escreveu:

I have 2 pages on a windows store app project.

First page displays a pdf file in a small part of the page, and i have a button that when i press i open the other page with the pdf loaded in full screen.

On page1 i have this on its constructor:

this.NavigationCacheMode = NavigationCacheMode.Enabled;

Im using PDFtron to view and edit the pdf files. on Page1 OnNavigatedTo method i have this

pdftron.PDFNet.Initialize();
MyPDFViewCtrl = new pdftron.PDF.PDFViewCtrl();
PDFViewBorder.Child = MyPDFViewCtrl;
MyToolManager = new pdftron.PDF.Tools.ToolManager(MyPDFViewCtrl);
pdfViewer.Visibility = Visibility.Visible;

and this on xaml:

to open the pdf i have something like this:

folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(Constants.DataDirectory, CreationCollisionOption.OpenIfExists);
file = await folder.CreateFileAsync(document.fileName, CreationCollisionOption.OpenIfExists);
docpdf = new PDFDoc(file);
MyPDFViewCtrl.SetDoc(docpdf);
Debug.WriteLine(MyPDFViewCtrl.GetPageCount());

So the problem is this: When i enter page1, it displays the pdf correctly, i then press the button and navigate to page2 where it shows the file in fullscreen correctly, when i go back to previous page the file seems to be loaded correctly to the docpdf variable (it shows the correct number of pages on the Debug.WriteLine) , but it doesn’t show on the MyPDFViewCtrl, i get a empty Green Square.

Do i need to enable any sort of parameter?

Thank you for the update. Would you mind updating your StackOverflow question? Others might run into the same thing as you.