Control Navigation

If you need to move between pages, you can use links to move between them but in Windows Phone 7 you need to take care of the Back button that every phone has. One way to do that is overriding the OnBackKeyPress event with something like this:

        protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
        {
            //Call a function in your script that evals if you need to move back.
            widget.InvokeScript("eval", new string[] { "yourWidget.backHistory()" });

            if (manageWidget == 2)
                base.OnBackKeyPress(e);
            else
                e.Cancel = true;                
                
        }


yourWidget.backHistory() = function(){
	if ( somethingToEvaluateToKnowWhereToGo ){
                    //Move to previous page
                    window.external.Notify("Back()");
                } else{
                    //End the execution of the app
                    window.external.Notify("HistoryBackEnd()");
	}
}

Last edited May 12, 2011 at 2:23 PM by onir, version 1

Comments

ddobric Feb 4, 2012 at 10:05 PM 
Did you try with Javascript navigate and location?

onir Jun 28, 2011 at 4:26 PM 
In you JS files

kathweaver Jun 18, 2011 at 3:48 PM 
Where does the second block of code go?