×
Namespaces

Variants
Actions

Talk:Solving Circular Navigation in Silverlight for Window Phone

From Nokia Developer Wiki
Jump to: navigation, search

Contents

Hamishwillee - Subedited

Hi Jeffrey

Thanks very much for this translation. This is clearly useful for English programmers too!

I've subedited this for readability. What you had wasn't bad, but I believe it is now clearer what this article delivers.

IMO the most common circular issue this is to solve is ensuring that from Home you always exit the app when you press back (it is quite possible that other loops in the app are fine). If this is the only case you are worried about it might be better to simply force this navigation path from your home page (ie overload pressing of the back button to exit the app). Is this possible?

IF it is possible then my suggestion would be to add a section showing how to do this as well. This would then provide a number of options for developers, depending on what their navigation needs are.

Regards

Hamish

hamishwillee 04:25, 2 October 2012 (EEST)

Jeffrey.Halimsetiawan - Answer

Hi Hamish,

Actually, this solution is used to overcome circular navigation in my game. I already tried to overload pressing of the back button and in that method, I call NavigationServices.GoBack() or force it to go to the correct page. But it just make confused to manage the navigation of my application. Therefore, I used this library so I just know which page should I go and this library will take the rest.

Regards,

Jeffrey

Jeffrey.Halimsetiawan 10:36, 2 October 2012 (EEST)

Hamishwillee - I do understand that

Hi Jeffrey

I do understand that if you want to remove all loops in your software this is the easiest way to do so. However there will be cases where you don't want to untangle "all" loops - you just want to ensure that selecting back from the home page will close close the app. In this case, you could just overload back on the home page - right?

So I like what you've done and I see that it makes perfect sense for your app. My suggestion is that for some apps just overloading back on the home page would be easier and sufficient for their navigation.

Regards

Hamish

hamishwillee 04:16, 3 October 2012 (EEST)

Jeffrey.Halimsetiawan - Answer

Hi Hamish,

From your explanation, I don't understand with this sentence "However there will be cases where you don't want to untangle "all" loops". Could you please give me example of that navigation? Because I think that as long as we have "loop", we could just overload back keypress method but we need to do that in each loop page in order to make sure that it goes to correct page in application back-stack.

This is what I got from your explanation: - MainPage

 NavigationService.Navigate(new Uri("/GamePage.xaml", UriKind.Relative));

- GamePage

 NavigationService.Navigate(new Uri("/StagePage.xaml", UriKind.Relative));

- StagePage

  protected virtual void OnBackKeyPress(CancelEventArgs e ) 
  {
       NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
  }

- MainPage

 protected virtual void OnBackKeyPress(CancelEventArgs e ) 
  {
       NavigationService.GoBack();
  }
  

Sorry if there is a misunderstanding and please correct me if I'm wrong.

Thanks.

Jeffrey.Halimsetiawan 05:27, 3 October 2012 (EEST)

Hamishwillee - Hmmm, not sure how I can better explain

Hi Jeffrey

I'm not sure how I can better explain. I will try below, but if it doesn't make sense, just ignore me and I'll delete these comments.

OK, so in your example you always want to remove all loops, and you also want to exit if back is pressed in mainpage. However what if you have an app where you (still) want to exit if back is pressed on mainpage, but you do NOT want to remove (other) loops in the navigation?

My proposed solution would be to override OnBackKeyPress (in MainPage only) with a call that exits the app (like "app.Exit()", if such a method exists). Then any other loops are followed, but if you press back in MainPage the app exits. Its a simpler implementation if you don't care about loops other than ones that might stop you exiting in MainPage

Does that make sense? As above, if not then lets forget it.

Regards

H

hamishwillee 07:14, 4 October 2012 (EEST)

Jeffrey.Halimsetiawan - Not possible

Hi Hamis,

Now, I get your point. And, I think it doesn't make sense. As far as I know, there is no method that can be used to exit application like app.Exit(). The only way to exit the application is to clear the application back-stack. So, you must use GoBack() until reach the first page you've visited in your app.

That's way I don't understand what do you mean. Sorry for the misunderstanding.

Thanks.

Jeffrey.Halimsetiawan 12:44, 4 October 2012 (EEST)

Hamishwillee - Thanks very much for your patience

Hi Jeffrey

Thanks very much. Sorry for wasting your time on something "impossible". The fact you can't arbitrarily exit an app is useful for me to know!

Cheers

H

hamishwillee 06:39, 5 October 2012 (EEST)

 

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×