是OnNavigatedTo还是Loaded事件?我已经可以互换使用两者,但是我想清楚地知道哪一个先出现。
最佳答案
OnNavigatedTo首先触发-来源-一个简单的实验
见下面的代码public partial class MainPage : PhoneApplicationPage { // Constructor public MainPage() { InitializeComponent(); Loaded += new RoutedEventHandler(MainPage_Loaded); } void MainPage_Loaded(object sender, RoutedEventArgs e) { throw new NotImplementedException(); } protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { base.OnNavigatedTo(e); } // Simple button Click event handler to take us to the second page private void Button_Click(object sender, RoutedEventArgs e) { NavigationService.Navigate(new Uri("/GamePage.xaml", UriKind.Relative)); } }