【问题标题】:Windows Phone NavigationService jumpsWindows Phone NavigationService 跳转
【发布时间】:2013-03-12 10:07:45
【问题描述】:

我有一些 xaml 页面,我们称它们为 1、2、3 等。

当从 1 导航到 2 时,整个页面在加载页面时会向上跳跃一点然后恢复正常,如果从 2 导航到 3 也会发生同样的情况。

虽然当使用 navigationservice.GoBack() 向后导航时;方法,从 page3 到 page2 或 page2 到 page1 页面转换都是平滑的,中间没有跳转。

我遇到的跳跃只会在向前导航时发生,这可能是问题所在,因为它有点烦人,我想解决这个问题。

我如何向前导航的示例:

NavigationService.Navigate(new Uri("/page2.xaml", UriKind.Relative));

Xaml 布局:

<Grid x:Name="LayoutRoot">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <!--TitlePanel contains the name of the application and page title-->
    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
        <TextBlock x:Name="ApplicationTitle" Text="Blablabla secret" Style="{StaticResource PhoneTextNormalStyle}"/>
        <TextBlock x:Name="PageTitle" Text="More blablabla" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
    </StackPanel>

    <!--ContentPanel - place additional content here-->
    <ScrollViewer Height="500" HorizontalAlignment="Left" Margin="18,0,0,0" Name="scrollViewer1" VerticalAlignment="Top" Width="450" HorizontalScrollBarVisibility="Disabled" Grid.Row="1">
        <StackPanel Height="Auto" Name="stackPanel1" Width="450">
            <TextBlock Height="54" Name="textBlock1" Text="" TextWrapping="Wrap">
                <Underline FontSize="40">page2</Underline>
            </TextBlock>
            <TextBlock Height="400" Name="textBlock2" Text="Blablablabla" TextWrapping="Wrap" FontSize="26" />

        </StackPanel>
    </ScrollViewer>
    <my:AdControl AdUnitId="000000" ApplicationId="ffffff" Grid.Row="1" Height="80" HorizontalAlignment="Left" Margin="0,455,0,0" Name="adControl1" VerticalAlignment="Top" Width="480" />
    <Grid.Background>
        <ImageBrush ImageSource="/Blablaapplication;component/Images/Secret.png" />
    </Grid.Background>
</Grid>
<phone:PhoneApplicationPage.ApplicationBar>
    <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
        <shell:ApplicationBarIconButton IconUri="/Images/appbar.Back.rest.png" Text="Back" Click="Backbutton"/>
        <shell:ApplicationBarIconButton IconUri="/Images/appbar.next.rest.png" Text="Next" Click="Nextbutton"/>
    </shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>

【问题讨论】:

  • 您需要展示一些xaml,以便我们了解各个页面的布局。
  • @Gambit 现在编辑并包含 xaml 代码! :)
  • 我无法重现您所描述的内容,但发现这可能会有所帮助:softwarenerd.org/archives/449
  • 听起来像是描述我的问题的好来源!我调查一下。 :) 我认为这是我在每个页面上的应用程序栏弄乱了它,我仔细查看了在我的物理设备上运行它,并慢慢注意到它正在为每个页面重新加载应用程序栏,从而使整个页面上升一秒钟。我会试试这些方法! :)

标签: c# visual-studio-2010 windows-phone-7


【解决方案1】:

您是在物理设备还是模拟器上进行测试?您使用的是什么版本的 SDK/OS?

然而,我个人之前从未遇到过这个问题,据我记得一些开发人员认为这个问题的解决方案是通过核心调度程序强制导航推送 (NavigationService.Navigate)。

基本上:

Dispatcher.BeginInvoke(() =>
    {
        NavigationService.Navigate(new Uri("/Page1.xaml", UriKind.Relative));
    });

【讨论】:

  • 我在物理设备和当前运行 os 7.8 的模拟器上测试这个。好吧,我今天晚些时候会试试这个,我告诉你它是否有效! :) @Den Delimarsky
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-27
  • 1970-01-01
  • 1970-01-01
  • 2012-05-02
  • 2014-08-22
  • 1970-01-01
相关资源
最近更新 更多