Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public MainPage(){
- InitializeComponent();
- if (phoneAppService.State.TryGetValue("currentLanguage", out someObject))
- { // Yes: go on
- var uri = "/Pages/Page_A.xaml";
- this.Dispatcher.BeginInvoke(() => this.NavigationService.Navigate(new Uri(uri, UriKind.Relative)));
- }
- else
- { // No: select language before proceeding
- var uri = "/Pages/Page_B.xaml";
- this.Dispatcher.BeginInvoke( () => this.NavigationService.Navigate(new Uri(uri, UriKind.Relative)));
- }
- }
- **// if previous page was Page_A or Page_B then exit application**
- protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
- {
- string sourcePage = "";
- if (NavigationContext.QueryString.TryGetValue("from", out sourcePage)) {
- if ((string.Compare(sourcePage.ToString(), "Page_A")) == 0 ? true : false) {
- **// EXIT APPLICATION**
- }
- if ((string.Compare(sourcePage.ToString(), "Page_B")) == 0 ? true : false) {
- **// EXIT APPLICATION**
- }
- }
- base.OnNavigatedTo(e);
- }
- // Back Button pressed: notify MainPage so it can exit application
- protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
- {
- NavigationService.Navigate(new Uri(uri, UriKind.Relative));
- base.OnBackKeyPress(e);
- }
- // Back Button pressed: notify MainPage so it can exit application
- protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
- {
- var uri = "/MainPage.xaml?from=Page_B";
- NavigationService.Navigate(new Uri(uri, UriKind.Relative));
- base.OnBackKeyPress(e);
- }
- RootFrame.Navigated += RootFrame_Navigated;
- void RootFrame_Navigated(object sender, NavigationEventArgs e)
- {
- var pageBURI = "/Pages/Page_B.xaml";
- var pageAURI = "/Pages/Page_A.xaml";
- if ((e.Uri == pageAURI || e.Uri == pageBURI) && RootFrame.BackStack.Count() > 0)
- {
- RootFrame.RemoveBackEntry();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement