Change MainPage OR HomePage programmatically from 'App.xaml.cs' in WinRT RRS feed

  • Question

  • Hi,

    I want to change the Landing Page of my Windows Phone WinRT App like when user set Application PIN LOCK user will get the VerifyPin.xaml at the start and after verifying MainPage.xaml will appear. And if user did not setup PIN LOCK then he will be transferred to MainPage.xaml at the start.

    I have found this silverlight code to do that but as you know it wont work in WinRT so someone please guide me through some workaround

    public sealed partial class App : Application { public static PhoneApplicationFrame RootFrame { get; private set; } public App() { RootFrame.Navigating += new NavigatingCancelEventHandler(RootFrame_Navigating); } void RootFrame_Navigating(object sender, NavigatingCancelEventArgs e) { if (e.Uri.ToString().Contains("/MainPage.xaml") != true) return; e.Cancel = true; RootFrame.Dispatcher.BeginInvoke(delegate { if (PinCode == true) RootFrame.Navigate(new Uri("/PinVerify.xaml?method=cancel%20navigation", UriKind.Relative)); else RootFrame.Navigate(new Uri("/HomePage.xaml?method=cancel%20navigation", UriKind.Relative)); }); }


    At this time there is only one problem that in WinRT there is no 'PhoneApplicationFrame' so I cant get this code to work

    • Edited by xSHERU Friday, August 1, 2014 1:55 PM
    Friday, August 1, 2014 1:52 PM


  • Implement this case in WinRT is simpler, then on WP. because on WinRT we don't set a entry point page in app manifest file. This is managed in App.xaml.cs.

    In OnLaunched method when you've initialized your Frame, just check some condition and navigate to page what you need.

        rootFrame.Navigate(typeof(HomePage), e.Arguments));
        rootFrame.Navigate(typeof(Mainpage), e.Arguments));

    • Edited by Oleg Kurzov Friday, August 1, 2014 3:13 PM
    • Marked as answer by xSHERU Friday, August 1, 2014 3:13 PM
    Friday, August 1, 2014 3:11 PM