如何在wp7中刷新页面

时间:2012-10-12 05:33:43

标签: c# windows-phone-7

如何在wp7中刷新页面我试过这段代码

NavigationService.Navigate(new Uri(string.Format(NavigationService.Source +
                                        "?Refresh=true&random={0}", Guid.NewGuid()));

但是它给出了错误

Navigation is only supported to relative URIs that are fragments, or begin with '/', or which contain ';component/'.
Parameter name: uri

请尽快向我发送解决方案。

3 个答案:

答案 0 :(得分:4)

你不能直接把你的页面的URI?另外,明确将URI设置为相对URI。类似的东西:

NavigationService.Navigate(new Uri(string.Format("/MyPage.xaml?Refresh=true&random={0}", Guid.NewGuid()), UriKind.Relative);

答案 1 :(得分:0)

请尝试以下forum中的以下帖子:

“看起来UriMapper对象没有针对框架创建。将UriMapper属性添加到Frame并将其指向设置映射的资源似乎已经修复了它。所以在页面中包含框架xaml现在看起来像......“

<navigation:Frame Grid.Row="1" x:Name="Frame" 
                                  HorizontalContentAlignment="Stretch"
                                  VerticalContentAlignment="Stretch"
                                  Padding="0"
                                  Background="White"
                                  JournalOwnership="OwnsJournal"

                                  UriMapper="{StaticResource uriMapper}"    />

在App.xaml应用程序资源中我有....

<navigationCore:UriMapper x:Key="uriMapper">
<navigationCore:UriMapping Uri="Contracts" MappedUri="/Views/Contracts.xaml" />
</navigationCore:UriMapper>

答案 2 :(得分:-1)

我认为KooKiz的方法是正确的。

我不知道你为什么会崩溃。你在新的一个后备箱后清理你的后背架吗?