我解決了這樣的問題: 我在頁面B(VehiclesPage.xaml)上創建了public static int'pageIndex',並且我可以從另外4頁訪問頁面B,所以我在更改索引之前從每個頁面導航到B頁。例如:
From A->B
VehiclesPage.pageIndex = 1;
this.NavigationService.Navigate(new Uri("/View/VehiclesPage.xaml", UriKind.Relative));
From D->B
VehiclesPage.pageIndex = 2;
this.NavigationService.Navigate(new Uri("/View/VehiclesPage.xaml", UriKind.Relative));
etc...
而上VahiclesPage.xaml.cs方法:
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
{
base.OnBackKeyPress(e);
switch (pageIndex)
{
case 1:
NavigationService.Navigate(new Uri("/View/RefuelingPage.xaml", UriKind.Relative));
break;
case 2:
NavigationService.Navigate(new Uri("/View/OtherCostsPage.xaml", UriKind.Relative));
break;
case 3:
NavigationService.Navigate(new Uri("/View/StatisticsPage.xaml", UriKind.Relative));
break;
case 4:
NavigationService.Navigate(new Uri("/View/CalculatorPage.xaml", UriKind.Relative));
break;
}
}