I'm totally new to windows phone development. Actually I try to implement my navigation flow for my application.
I want to achieve this simple flow:
- When the app start, I check if the user is already logged in
- then, I navigate to the MainPage and so on
- else I navigate to the login page
- the user proceed the login page and go to the main page if the login succeed
I'm already try some solution like:
in App.xaml.cs
UriMapper mapper = Resources["uriMapper"] as UriMapper;
RootFrame.UriMapper = mapper;
Uri loginPage = new Uri("/LoginPage.xaml", UriKind.Relative);
Uri mainPage = new Uri("/MainPage.xaml", UriKind.Relative);
if (!ClientApi.IsAuthenticated)
{
mapper.UriMappings[0].MappedUri = loginPage;
}
else
{
mapper.UriMappings[0].MappedUri = mainPage;
}
Work but I can't navigate to other page in my application after login
I override OnNavigatedTo(NavigationEventArgs e) in my MainPage
if (!App.ClientApi.IsAuthenticated)
{
NavigationService.Navigate(new Uri("/LoginPage.xaml", UriKind.Relative));
}
but when I hit the back button the app doesn't go back and stuck on the login page.(well I understand why. the previous page it's the mainpage and I override the OnNavigatedTo that cause a loop)
What am I doing wrong?
PS:
I'm using
- MVVM light (and Navigation based messaging describe in this post)
- Windows Phone 8