1.In<Phone: phoneapplicationpage
WriteBackkeypress = "phoneapplicationpage_backkeypress"EventThis event is triggered when the user presses the back object key.
Silverlight does notProgramExit Mechanism, so we have adopted the zookeeper throwing exception method to exit the application.
2. implement this phoneapplicationpage_backkeypress event
// Exit the application
Private void phoneapplicationpage_backkeypress (Object sender, system. componentmodel. canceleventargs E)
{
Try
{
Messageboxresult res = MessageBox. Show ("are you sure you want to exit? "," Prompt ", messageboxbutton. okcancel );
If (RES = messageboxresult. OK)
{
}
Else
{
E. Cancel = true;
}
}
Catch
{
}
}
3. Define an exception class. No exit mechanism exists in SL. Therefore, the program exits by throwing an exception.
Public class quitexception: exception
{
Public static void quit ()
{
Throw new quitexception ();
}
}