【问题标题】:Windows Phone 8.1 Hyperlink button and save stateWindows Phone 8.1 超链接按钮和保存状态
【发布时间】:2014-06-10 22:08:59
【问题描述】:

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

<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 中工作,而不是共享应用程序。

【问题讨论】:

  • 您的意思是 Windows Phone 8.1 Silverlight?
  • 它们在 8.1 中被称为 Windows Phone RT XAML 应用程序
  • 其实两者都存在,但问题清楚地说明了使用的是哪一个。
  • 是的,不是 8.1 Silverlight,而是 Phone 8.1 RT。截至今天 2014 年 6 月 10 日,很难找到有关 Phone 8.1 RT 的广泛帮助,因为搜索总是以 Windows 8.1(不是手机)或 Phone 8.1 Silverlight 结束。
  • 问题可能与暂停/恢复应用程序有关 - 附加调试器时,应用程序 not raising those events。你在Suspending 有什么东西吗,你能测试一下当这个事件被引发时你的应用会发生什么吗?

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


【解决方案1】:

嗯,好像我用错了方法。 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 中

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多