c# - Windows Phone 8.1 how to display Progress Ring when Navigating to another Page? -


completely new winphone8.1:

my winphone8.1 app seems navigate quite between pages - each page question , have previous/next buttons:

private void btnnextquestion_click(object sender, routedeventargs e)     {         progressring1.isactive = true;         frame.navigate(typeof(question), _survey.id.tostring() + "|" + _nextfield.id.tostring());     } 

as can see tried set progressring1.isactive = true; didn't expect work, tried anyway. tried clever , use task (which new me - maybe i've done wrong) start progressring didn't have effect either:

private async void btnnextquestion_click(object sender, routedeventargs e)     {         await task.run(() => startprogrssring());         frame.navigate(typeof(question), _survey.id.tostring() + "|" + _nextfield.id.tostring());     }      private void startprogrssring()     {         progressring1.isactive = true;     } 

so explain how can achieve aim - let user know button press has been recognised , app processing it.

you need let ui thread run bit refresh ui. there's many ways reach result, 1 i'd suggest here call task.delay:

private async void btnnextquestion_click(object sender, routedeventargs e) {     progressring1.isactive = true;      // wait 2 ms let ui thread execute     await task.delay(2);      frame.navigate(typeof(question), _survey.id.tostring() + "|" + _nextfield.id.tostring()); } 

why 2 ms? because need give ui thread @ least 1.6 ms (the duration between each frame) make sure ui refreshed. otherwise, may execute call frame.navigate without refreshing ui.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -