Windows Phone Universal - Issue in Navigation and On Loading of page - windows-phone-8.1

I am facing a weird problem in windows phone 8.1 page navigation.
I have got two pages.
Login page > Consists of app bar in which one of the button take us to second page.
Second page is Cached using MVVM i.e Registered the Second page to IOC on launch of app and binding the instance of it to page 2 XAML.
In the Second page View model Constructor I am making Server call to get the data.
Problems facing.
On Clicking the app bar button to navigate to second page, the app stays in the first page until the second page make server call and get the response. Then its navigating.
But actual behavior must be it should navigate to second page and wait there to get response showing progress bar.
One quick fix is I made the thread to stop for some 50 millisecond in page 2 constructor of view model and then made service call
It navigated to Second page immediately and waited there until response but the previous page App Bar still displays until I get the response.
I even find the quick solution for it by Collapsing the App bar just before Navigating to that page.
I know these quick fixes are not good. So please help me to find out the problem or if you already know please revert back with the solution.

Don't use constructor to initiate the web service calls . Use OnNavigatedTo or Page_Loaded event .

Related

popToViewController presenting a black view

I have an app that has many different views. The entry point to the app is the home page where I have 2 buttons (note that the home page is embedded in a navigation controller). Each button leads to a new stack of views, I tried embedding the first view of those stacks into a navigation controller, but when I push a button on the home page that leads to a new stack, the app crashes giving me a "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'" message. So I avoided embedding the stacks into a nav controller. The problem happens when I push the save button in the last view of the stack. In there I did the usual
self.navigationController?.popToViewController(firstViewController, animated: true)
This does not work and I get sent to the firstViewController, however the navigation bar buttons don't show up, the background is black and nothing shows. If I popToRootViewController however, it works. Cheers!
Alright well I feel stupid now, I realized that the segues between my buttons and view controllers were push segues. Now I embedded the first view controller of both stacks in a navigation controller, and changed my segues into modal segues. By doing that I was able to use popToRootViewController instead of popToView Controller... Now my save button leads back to the view controller I wanted to show, everything works fine.

Back Key doesn't terminate the app and doesn't back to mai page

I'm working in a Windows Phone 8.1 Project and have created it from a WP blank page (XAML and C#). After that added a new blank page and I navigate from main page through a blank page using a button. Now I'm struggling to navigate between pages.
If I'm at main page and press the physical back key button of my cellphone, my app doesn't terminate, instead it goes to background.
If I'm at blank page and press the physical back key button of my cellphone, my app doesn't go back to main page, instead it goes to background.
I have tried several methods from internet (most of them using silverlight which is not my case) but I didn't understand how to create an event handler to deal with that.
Navigation doesn't work in 8.1 because it isn't built in by default as it was in 8.0. You either have to do it yourself or instead of using a new Blank Page use a Basic Page.
The first time you add a Basic Page to your project the IDE will automagically add all the stuff to do automatic back page navigation. It will add a new NavigationHelper class under the Common directory. It will also add NavigationHelper methods to the page where you can add code for recreating the page after a terminate and resume.

Windows Phone Application Bar Instance Remaining Same When Back Key Pressed

I Have Created an application bar in the First Page and when a click occurs, it navigates to the Second Page and creates a new Application Bar in CodeBehind c#.
Till here it is Working fine but when i press the Back Hard Button while on the second page, the application bar instance is still remaining and appearing in first page.
In the ONNAVIGATEDTO method i'm making the instance of the first page appbar as null but it is not working and the previous application bar (of the Second Page) is still showing in the firstPage.
The application bar is different for each page. No need to create it in code behind.
The null assignment does not work because the appbar is not rendered yet. If you insist of doing it in code behind, which is not recommended, do it on page load. There is also an Items.Clear() method you can use to remove the app bar items. You should do it in XAML though.

How can I make my web page not auto refreshing when comming back using back button?

I am developing a web page and I am testing it using httpd web server and Firefox. That page is a simple serach engine - providing key words and relevant items will be displayed using AJAX.
My question comes here, every time I click those items to go to another page and try to come back using the browser’s back button, all the contents disappeared and I have to search again.
How can I keep those items?
Take a look at google.com and what happens when you type but do not press enter.
Then read this
Modify Address Bar URL in AJAX App to Match Current State

WebResource.axd Suddenly Stopped Working In ASP.Net Offline Web App

Building an offline web app in VS2010. I have a master page with a navigation menu control. So far I've been able to add 4 new pages, each navigated to from this menu control. All has been added to the Cache Manifest file and all has worked offline up until now. After the most recent page was added to the project, now when I am offline, my menu control doesn't load properly and the console shows that the webresource.axd for the menu control couldn't be found and then gives the sys is not defined error. The error does not occur just by navigating to a page, only when button is clicked that causes a location.reload(true).
I've seen from VS where things will be working and then when you restart VS the next morning stuff will suddenly be broken. But I mean this is really blowing my mind.
Is there another way maybe to refresh an offline page such that the controls reset back to original value? That is the only reason I am doing the refresh.
It was something so simple I am embarrassed. I changed location.reload(true) to location.reload(false). That way, it wasn't trying to reload the page from the server. All fixed.