Reputation: 2012
I am having an WP7 application in which I need to change the Startup page depending upon if the user is already registered or not. Suppose if user is registered then I need to redirect him to welcome page if not then to register page.
I have tried a couple of ways below is my code but it gives me an argument dispose exception.
To achieve above feature I wrote Navigation code in my MainPage.xaml constructor. Checked if the User Registration info is not in isolated storage then will redirect to other page.
private void IsAgreeed()
{
try
{
isoStorage = IsolatedStorageFile.GetUserStoreForApplication();
if (!isoStorage.FileExists("DataBase/MyPhoneNumber.txt"))
{
this.NavigationService.Navigate(new Uri("/EULA.xaml", UriKind.Relative));
}
else
{
return;
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
}
}
Above code works properly when I use it first time but if I Close the Application and restart it again it throws exception argument dispose exception.
Thanks; nil
Upvotes: 1
Views: 1672
Reputation: 2012
To achieve this I put up MainPageorEula.xaml and got the functionality required.
Upvotes: 0
Reputation: 14882
Peter Torr covers page redirections quite well here. Two methods are offered with relative merits covered. Edit: Note you can redirect to a login page, rather then employing the popup suggestion for login handling.
Redirecting an initial navigation - Peter Torr's Blog
I'd also recommend familiarising with his accompanying post on places here.
Introducing the concept of “Places” - Peter Torr's Blog
This address back stack handling (certification consideration) and addresses scenarios such as login pages.
Upvotes: 3
Reputation: 27353
Peter Torr explained 2 techniques for your purpose.
Redirecting an initial navigation
Upvotes: 1