在我的主页中,我尝试导航到另一个页面(这是一个全景页面),我的主页 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
但是当我在主页上使用一个按钮,并将这个导航添加到它的点击事件中,那么它工作得非常好!可能是什么问题呢?提前致谢!