I know this has been discussed ad nauseum, but I want to present my case....
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.
When a user starts my app, and they already have a saved username in isolated storage, they are redirected to mainpage.xaml
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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With