I Have a very similar situation to this guys question in that 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 a user has not set a password yet. Essentially this is the first time that the App loads after it has been installed.
I've spent hours on SO trying various different solutions (including the one I linked to) but I'm just not getting anywhere and it seems that many of the solutions are either for WP7 or WP8 and nothing similar has been solved for the new WP8.1.
This is the basic check, using Windows.Storage that I'm doing to see 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 public MainPage()
class I have no problem in the app returning "Password is not set" in the debug messages however the this.frame.Navigate(typeof(SetPassword))
navigation never loads the SetPassword view.
I have also tried this method in the OnNavigatedTo
with exactly the same results.
In my App.xaml file I've also tried a number of different methods, again, with the same results. I can get the debug message but not the navigation I'm looking for. I looked at implementing a method on Application_Launching
over here as well as implementing conditional navigation on RootFrame.Navigating+= RootFrameOnNavigating;
over here but clearly I am missing something.
Hopefully you smarter people can help me get my navigation working based on a conditional value?