views:

127

answers:

3

As stated by Microsoft, it's not possible to programatically navigate from the main page. I have a EULA page that I need to show if the user is using the app for the first time. My plan was to determine on the main page if the app has been used before. If not, I had planned to navigate to the EULA page, but this is not possible. How can I get around this navigation limitation?

+2  A: 

It should be possible to navigate from the main page easily using:

if (!eulaAgreed)
    NavigationService.Navigate(new Uri("/EULAPage.xaml", UriKind.Relative));

Probably best to put this code in OnNavigatedTo of your main page or even later in the page cycle using Dispatcher.BeginInvoke(...). Putting it before that (i.e. in the constructor or Loaded) may not work.

Technium
+1  A: 

What do you think happens to the Navigation stack? Would the users be able to access the EULA page again? maybe by clicking back from the MainPage ?

+2  A: 

The issue with a dedicated EULA page that is automatically pushed on the back stack is that the application won't quit when the user presses the Back key when in the EULA page.

You should instead use a Popup control that you show and hide when appropriate.

See Peter Torr's post on how to exit an application for more details and background.

Andréas Saudemont