【问题标题】:navigation service navigation pivot error导航服务导航枢轴错误
【发布时间】:2013-07-12 13:35:55
【问题描述】:
this.NavigationService.Navigate(new Uri("/MainPage.xaml?pivott.SelectedIndex = 0", UriKind.Relative));

我正在使用此代码导航我的数据透视索引 = 0,它只工作一次。当我要求第二个时,我的程序会停止。不退出而是停止。这是什么原因?我该如何解决?

【问题讨论】:

    标签: c# windows-phone-7 navigation pivot


    【解决方案1】:

    我不知道你在做什么。但我知道情况是在导航时将枢轴索引更改为 1。好的,我将为您动态选择枢轴索引。

    在我将导航到 Sample.xaml 的主页中:

    NavigationService.Navigate(new Uri("/Sample.xaml?id=1", UriKind.Relative));

    在 Sample.xaml 中输入以下代码:

     protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            string index;
            int number=0;
            if (NavigationContext.QueryString.TryGetValue("id", out index))
            {
                if (Int32.TryParse(index, out number))
                {
                    PivotItem.SelectedIndex = number;
                }
            }
        }
    

    通过改变主页面的id值来改变索引值。

    【讨论】:

    • 根据5.2.4.1,我对设备后退按钮有一些问题。我的应用程序有一个支点,并且有 2 个孩子。索引0和1。某处,我的应用程序切换到设备自己的短信发送组件,然后当用户按下后退按钮时,它返回到我的应用程序并等待枢轴索引1.microsoft不接受它。所以,我使用导航枢轴来跳转枢轴索引 0(在应用程序的开头)。代码一次有效,但第二次,它不起作用。你的代码不适合我。
    • 当您在主页面时,应用程序应在用户按下返回按钮时退出。当用户在手机上按下短信服务的返回按钮时,它显然会返回到应用程序,您要编写的代码应该是启动器完成事件。我将重写代码一次。并在您的问题中附上有关失败报告的更多详细信息。否则很难破译你在尝试什么
    猜你喜欢
    • 2011-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多