2

I have a hyperlink button in a pivot that navigates to a Url contained in an object in the ViewModel. When I press the button, I navigate to the url. But when I press the hardware back button, the phone navigates back to the start page.

<HyperlinkButton Content="Read More"
                 NavigateUri="{Binding Citation}"
                 BorderBrush="White"
                 BorderThickness="4"
                 Grid.Row="2"
                 HorizontalAlignment="Stretch"
                 Margin="10" />

When the debugger is attached, the back button navigates back to the app, which is what I want it to do. When it's not attached, and i've tested this on 5 devices and all the emulators, it goes back to the Start page list, and all the input that was supplied to the app is lost. The app seems to be cleared from memory completely. Help? PS I am working in Windows Phone 8.1 RT, not a shared app.

Romasz
  • 29,662
  • 13
  • 79
  • 154
BBH1023
  • 515
  • 2
  • 7
  • 18
  • You mean Windows Phone 8.1 Silverlight? – Mikael Dúi Bolinder Jun 10 '14 at 22:38
  • They are called Windows Phone RT XAML apps in 8.1 – Pantelis Jun 10 '14 at 23:00
  • 1
    Actually, both exist, but the question clearly states which one is being used. – Igor Ralic Jun 10 '14 at 23:02
  • yes, not 8.1 Silverlight, but Phone 8.1 RT. As of today 6/10/2014, it's pretty difficult to find extensive help for Phone 8.1 RT, since searches always end up with Windows 8.1 (not phone) or Phone 8.1 Silverlight. – BBH1023 Jun 11 '14 at 00:14
  • 1
    The problem miy be connected with Suspending/Resuming the App - while the debugger is attached the App is **not** [raising those events](http://stackoverflow.com/q/24103101/2681948). Do you have someting in `Suspending`, can you test what happens to your app when this event is raised? – Romasz Jun 11 '14 at 04:36

1 Answers1

0

Well, it seems as if I was approaching this the wrong way. Something new in Windows Phone 8.1 RT is the WebView. So no longer does the OS open an IE instance, you can open a webpage inline a grid. So:

<Button Content="Read More"
        BorderBrush="White"
        BorderThickness="4"
        Grid.Row="2"
        HorizontalAlignment="Stretch"
        Margin="10"
        Click="Citation_Click"/>

and then

    private void Citation_Click(object sender, RoutedEventArgs e)
    {
        Frame.Navigate(typeof(WebViewPage), this.equation.Citation);
    }

And in the WebViewPage.xaml.cs:

    private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
    {
        Uri nav = new Uri(e.NavigationParameter as string);
        _webView.Navigate(nav);
    }

where _webView is defined as:

 <Grid>
    <WebView x:Name="_webView"/>
 </Grid>

in WebPageView.xaml

BBH1023
  • 515
  • 2
  • 7
  • 18