windows 10 universal - UWP : Issue with the backbutton on my app -


i followed ms examples @ letter still encounter odd issue. let me explain :)

my app has 3 pages. main, add , help. main allows go add .navigate args. add allows go .navigate without args. add allows go main either backbutton or cancel button (the cancel button using goback()). can go add using backbutton.

my code pretty simple on main page define request :

in onnavigatedto() :

systemnavigationmanager.getforcurrentview().appviewbackbuttonvisibility = appviewbackbuttonvisibility.visible;             systemnavigationmanager.getforcurrentview().backrequested += mainpage_backrequested; 

the event handler :

private void mainpage_backrequested(object sender, backrequestedeventargs e)         {             if (this.frame.cangoback)             {                 this.frame.goback();                 e.handled = true;             }         } 

my issue following :

  • launch app => ok
  • main -> add -> = main ==> ok
  • main -> add -> -> = add ==> ok
  • main -> add -> -> = add -> = main ==> ok then
  • main -> add -> -> = main ???

when debugging, backstack ok. when hit issue, backrequested event handler indeed call twice (twice because hit "cangoback == false" presume), it's stuck in loop. idea ?

thanks.

and first of all, @mm8 , @avk. right, event registering many times. removing handler before adding again indeed not working in case (and don't understand why @ all, debugger show going through "-=" not removing looping once more every time went mainpage.

so, followed advice of martin zikmund @avk question (here) looked cleaner. instead of adding event handler @ end of onlaunched (basically, if launched app again when running, register yet handler), added in if(rootframe == null){ part. way seems work pretty well.

it's shame every piece of advice ms gives on handling backbutton pretty wrong don't think ?


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -