Search code examples
c#windows-phone-8popup

How to Navigate Back from Popup in Windows Phone8


here i have this problem with popup window, i popup an usercontrol in a dll and call this dll in an app, but it shows upon a black page that i have no idear where its from. when i push the '<-' button ,the app directly exit... i can't go back to the app's mainpage where calls it. I wonder how can I return from the popup window. I tried to hide the popup window, but it doesn't go back to app's mainpage.

public void change_PIN(OnCCB_ChangeUserPINCall changeUserPINCall) 
{
    Popup ppChangePIN = new Popup();
    ChangePIN changePIN = new ChangePIN();
    ppChangePIN.Child = changePIN;
    ppChangePIN.IsOpen = true;
}

How can I set ppChangePIN.IsOpen=false inside popup window .cs to make it disappear?


Solution

  • Handle back key press event of back button like

    step1: first set one flag when popup is open like **bool PopupOpen=True**

    step2: When popup is close at that time PopupOpen=False

     protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
        {
            if(PopupOpen== True)
            { 
              ppChangePIN.IsOpen=false;
    
             PopupOpen=False;
             e.Cancel = true;
            }
            else
            {}
        }
    

    If any query let me know...

    hope it work for you