Windows phone navigation immediately after loading the page

I have 2 pages (MainPage.xaml, second.xaml) MainPage.xaml is the login page. On this page, I send the login and password and get the result. I save them (the result) in Isolate Storage and go to the second.xaml page; The next time I run this application, I will extract the data from the isolated storage and I want to navigate the second .xaml, but I don’t know how

I'm trying to write

public MainPage() { InitializeComponent(); //function for Isolate storage InitializeSettings(); NavigationService.Navigate(new Uri("/Conversation.xaml", UriKind.Relative)); } 

But this is not work) I realized that I can’t use the navigation code associated with the MainPage () constructor. Of course, I can make a simple button, but I wish quick navigation

I think maybe this is due to the App.xaml method

 private void Application_Launching(object sender, LaunchingEventArgs e) 

for example write my method

  //function for Isolate storage InitializeSettings(); 

with navigation there? (navigation does not work in this example)

 private void Application_Launching(object sender, LaunchingEventArgs e) { InitializeSettings(); NavigationService.Navigate(new Uri("/Conversation.xaml", UriKind.Relative)); } 

Where can I use navigation, go straight to the second.xaml page without fully loading MainPage.xaml (maybe without MainPage.xaml)

0
source share
2 answers

You can do as Rana Tallall said.

Or you can write it in code:

 public MainPage() { InitializeComponent(); Loaded += (s, e) => { InitializeSettings(); // Some login-password check condition if (_login && _password) NavigationService.Navigate(new Uri("/Conversation.xaml", UriKind.Relative)); } } 
+2
source

Well, create a new function ... and in it perform checks on which you want them to be moved, and if the checks are in order in it, than calling the navigation service navigationservice.navigate (....) code. Now you need to tell the program to call this function when the main page is fully loaded. To do this in the xml mainpage inside the tags at the end of it write loaded = "function_name" Now that the page is loaded, this function will be called. If login information is present in isolated storage, otherwise navigation calls will be called differently, the main page will be displayed.

Be sure to put (sender object, RoutedEventArgs e) in the function parameters (since this is an event handler).

+1
source

All Articles