c# - Handling Back Navigation Windows 10 (UWP) -


in xaml page i've got frame.

i'm trying have backbutton event navigate inside frame .

so tried use piece of code

public mainpage(){     this.initializecomponent();     if(windows.foundation.metadata.apiinformation.istypepresent("windows.phone.ui.input.hardwarebuttons")) {         windows.phone.ui.input.hardwarebuttons.backpressed += hardwarebuttons_backpressed;     } } private void hardwarebuttons_backpressed(object sender,backpressedeventargs e) {     if(insideframe.cangoback())insideframe.goback();     else  application.current.exit(); } 

but in phone after doing hardwarebuttons_backpressed event close application.

it seems running default button behavior on mainpage...

how can fix it? , in windows10 add new events handle navigation?


[update]

now found out it's better use systemnavigationmanager in windows 10 instead of input.hardwarebuttons.backpressed.

systemnavigationmanager currentview = systemnavigationmanager.getforcurrentview(); 

you need tell system handled backbutton press setting handled property of backpressedeventargs true.

  private void onhardwarebuttonsbackpressed(object sender, backpressedeventargs e)   {         // missing line!         e.handled = true;          // close app if on startpage         if (mmainframe.currentsourcepagetype == typeof(startpage))             app.current.exit();          // navigate         if (mmainframe.cangoback)         {             mmainframe.goback();         }   } 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -