Windows Phone 8.1超链接按钮和保存状态

时间:2014-06-10 22:08:59

标签: c# xaml windows-phone-8 windows-phone-8.1

我在数据透视表中有一个超链接按钮,可以导航到ViewModel中对象中包含的网址。当我按下按钮时,我会导航到该网址。但是当我按下硬件后退按钮时,手机会导航回到起始页面。

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

连接调试器后,后退按钮会导航回应用程序,这就是我想要它做的事情。如果没有连接,并且我已在5台设备和所有模拟器上对其进行了测试,则会返回到“开始”页面列表,并且提供给应用程序的所有输入都将丢失。该应用程序似乎完全从内存中清除。救命? PS我在Windows Phone 8.1 RT中工作,而不是共享应用程序。

1 个答案:

答案 0 :(得分:0)

好吧,似乎我正以错误的方式接近这一点。 Windows Phone 8.1 RT中的新功能是WebView。因此操作系统不再打开IE实例,您可以打开内联网格的网页。所以:

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

然后

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

在WebViewPage.xaml.cs中:

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

其中_webView定义为:

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

在WebPageView.xaml