Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Phone 7, login screen redirect and a case for .exit?

I know this has been discussed ad nauseum, but I want to present my case....

  1. My start page in my app is login.xaml. The user logs in, the username and password are authenticated through my WCF service, the username is saved in isolated storage, and then the user is redirected to mainpage.xaml.

  2. When a user starts my app, and they already have a saved username in isolated storage, they are redirected to mainpage.xaml

  3. If the user hits "back" hard button from mainpage.xaml, this redirects to the login screen, which in turn redirects them back to the mainpage.xaml since they already have a saved local username. This is causing my app to fail certification currently since the user cannot hit the "back" button to exit the app from mainpage.xaml.

My instinct here is to override the BackKeyPress in mainpage.xaml and exit the app somehow. By reading the other posts, I can see that this method is not available. My second idea was to somehow store a property in the app.xaml.cs page that would tell the app to exit when the login page is loaded and that property is set to true, but that seems a bit hacky as well....

Any ideas here?

UPDATE SOLUTION USED:

What ended up working was to make the login page a pivot item inside mainpage.xaml. When a user opened the app without being logged in, the currently selected pivot item would change to the login pivot item. If the user opened the app and WAS logged in, the normal pivot item would be selected.

like image 897
Jarrette Avatar asked Oct 10 '22 16:10

Jarrette


1 Answers

I do this by combining the login page and the main page into one page with two grids in a stackpanel and manipulating the visibility of the grids to switch between the UI required for anonymous and authenticated users. This makes the problem go away with no need to diddle the history or fiddle with flags.

With a suitable converter and appropriate bindings of Visibility properties I could probably run the whole show without explicit code, but that would be a good example of the difference between clever and smart - it works so well that sooner or later I'd forget how it works (ok I confess, I did this and forgot how it worked).

like image 54
Peter Wone Avatar answered Oct 14 '22 04:10

Peter Wone