【发布时间】:2013-10-30 15:52:04
【问题描述】:
在我的主页中,我尝试导航到另一个页面(这是一个全景页面),我的主页 c# 代码是,
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
namespace Panoramatry
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
displsy();
}
public void display()
{
NavigationService.Navigate(new Uri("/GettingStarted.xaml",UriKind.Relative));
}
}
}
而我的GettingStarted.xaml页面有以下代码,
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
namespace Panoramatry
{
public partial class GettingStarted : PhoneApplicationPage
{
public GettingStarted()
{
InitializeComponent();
display();
}
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
display();
}
public void display()
{
MessageBox.Show("Navigation Success");
}
}
}
但是在主页中执行导航代码时出现以下错误,
An exception of type 'System.NullReferenceException' occurred in Panoramatry.DLL but was not handled in user code
但是当我在主页上使用一个按钮,并将这个导航添加到它的点击事件中时,它工作得非常好! 可能是什么问题呢? 提前致谢!
【问题讨论】:
-
我从未听说过 Panoramatry.DLL,您的解决方案中有哪些第三方库?最重要的是,GettingStarted.xaml 中引用了哪些?
-
@FunksMaName 没有第三方库!!
-
尝试两件事,当你取下 display();打电话,你还有同样的问题吗?如果没有,将显示移动到 OnNavigatedTo 事件块中,查看是否仍然抛出错误 protected override void OnNavigatedTo(NavigationEventArgs e) { MessageBox.Show("Navigation Success"); base.OnNavigatedTo(e); }
-
仅供参考 Panoramatry 是我的项目名称!
-
更新了我的问题!请看一下!
标签: windows-phone-7 navigation