Navigation in Windows Phone 8.1 RT -
i'm working on windows phone 8.1 universal app. far having difficulties navigation between pages.
first mainpage. when click on post on mainpage opens page called postpage. postpage has buttons performs various operations. 1 of them opens page called commentspage. expected behavior when press button in commentspage go postpage instead goes mainpage.
how done? when press button, goes postpage , not mainpage.
i'm using following code handle button press
void hardwarebuttons_backpressed(object sender, windows.phone.ui.input.backpressedeventargs e) { if (frame.cangoback) { frame.goback(); //indicate button press handled app not exit e.handled = true; } }
update: how navigate page mainpage this.frame.navigate(typeof(postpage));
this problem caused subscribing backpressed event page, not unsubscribing it. means page instance kept alive, , backpressed event gets handled multiple event handlers; in case post page , comments page both handling event , both calling frame.goback().
to solve problem, unsubscribe backpressed event when leaving page, i.e. onnavigatedfrom() override.
Comments
Post a Comment