Search code examples
windowswindows-phone-8.1messagedialog

Windows phone 8.1 launch login ContentDialog on App Start before Mainpage


Please I am new to windows phone and any other platform development. I want to add a login screen to my app using ContentDialog. I have no clue and have found nothing by way of example on how to make it show before the mainpage.


Solution

  • @kennyzx thank you for pointing the link to me. here is hoe I solved my problem by placing the code below in my 'App.xaml.cs'

    protected async override void OnWindowCreated(WindowCreatedEventArgs e)
        {            
            //Lunch ContentDialog
            LoginPage signInDialog = new LoginPage();
            await signInDialog.ShowAsync();
    
            if (signInDialog.Result == SignInResult.SignInOK)
            {
                // Sign in was successful.
    
            }
            else if (signInDialog.Result == SignInResult.SignInFail)
            {
                // Sign in failed.
                // Exit the app after three attempts                
                Application.Current.Exit();
            }
            else if (signInDialog.Result == SignInResult.SignInCancel)
            {
                // Sign in was cancelled by the user.
                // Exit the app
                Application.Current.Exit();
            }
        }