I have a very similar situation to this guys question , because I have a login page, which is my MainPage.xaml file, but I have another page called SetPassword.xaml that I want to load if the user has not set a password yet. In fact, this is the first time the application loads after installing it.
I spent hours on SO trying different solutions (including the one I'm connected to), but I just don't get anything, and it seems like many of the solutions are either for WP7 or for WP8, and nothing like that has been solved for the new WP8.1.
This is a basic check using Windows.Storage, which I do to determine if a password has been set or not.
Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; Windows.Storage.StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder; if (localSettings.Values["myPassword"] == null) { Debug.WriteLine("Password not set"); this.Frame.Navigate(typeof(SetPassword)); } else { Debug.WriteLine("Password is set, continuing as normal"); }
If I add this to the public MainPage() class, I have no problem in the application returning "Password not set" in debug messages, however navigating this.frame.Navigate(typeof(SetPassword)) never loads the SetPassword view.
I also tried this method on OnNavigatedTo with exactly the same results.
In my App.xaml file, I also tried several different methods, again, with the same results. I can get a debug message, but not the navigation I'm looking for. I looked at the implementation of the Application_Launching method here , as well as the implementation of conditional navigation on RootFrame.Navigating+= RootFrameOnNavigating; here but obviously I'm missing something.
I hope you are smarter than people who can help me make my navigation work based on conditional values?