メインページで別のページ(パノラマページ)に移動しようとしましたが、メインページの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
しかし、メイン ページでボタンを使用し、このナビゲーションをそのクリック イベントに追加すると、完全に正常に動作します。何が問題なのですか?前もって感謝します!