How to make navigate between pages faster in windows phone - windows-phone-7

I'm doing an application on windows phone
I use this method to navigate between pages
NavigationService.Navigate(new Uri("/SecondPage.xaml",UriKind.Relative));
But if I navigate between 2 complex pages (e.g many images on these), the system delay quite a lot of time(2-3s) for navigating
I want to navigate to next page before loading data in second page, when navigating completed then just start loading data for this page
it should be like MARKET PLACE app in PHONE Device, it's so fast

The page constructor and code in the Loaded event handler are executed before the first frame of the page is shown.
So if you want pages to be loaded fast, you should limit long-running operations like loading images in these methods.
One way that you can do this is to override OnNavigatedTo and start long-running operations in this method. OnNavigatedTo is called when a page becomes the active page.

Related

Loading a website without browser showing spinning wheel

I am just curious to know how these websites were made to load only once. If you go to the sites http://fueled.com/ or http://ecap.co.nz/, the browser shows the spinning wheel only the first time the website is loaded. When you navigate to other pages from the navigation menu, like About or Contact or Team, when those pages load, the browser doesn't show the spinning wheel.
How do they make them work like this?
It is because page load is not triggered upon those links. Instead, a post request is triggered and its response will be used. Also, further page loads will be quicker, since scripts, styles and pictures will be cached, that is, saved locally on your computer.
You can check what happens using the browser console's network tab. Click on the last request before you click on such a link. You will see that the request log will not be cleared, but other requests are added. That means there is no page load in the meantime.

Too many FB share button request

I'm optimizing my site speed. One of the main issue I'm facing is the homepage.
In the homepage, each article has FB/TW share buttons.
I only inserted the scripts in the footer once but I'm getting bunch of FB/TW share button requests.
Is it normal or there is something I need to do?
For every Like/Share button that you have, your browser needs to make a request to get the content. This is only executed when the browser has received the page from your server, so it does not affect the initial load time.
As CBroe mentions, the button is displayed in an iFrame. These are loaded and depending on your browser settings all at the same time or consecutive. During this time, your browser is not blocked so your used can already interact with the page.
If you want to reduce load, the only option is to remove the buttons. I think you have some index/home page where you load all the articles and for each of those a button? You could consider only showing the buttons on the articles itself, if you are really concerned about this.
But, since this is normal behaviour and your page is not blocked by loading all the iframes, this is not a big issue nor can you optimise it yourself.

constructor vs. onNavigatedTo

I am confused what I should do in constructor and what else should I do in a onNavigatedTo method in a Windows Phone page.
Particularly, where should I read storage and settings?
onNavigatedTo is performed all the time when you navigate to this page, i.e. after navigation back from another page or deactivation application.
Page constructor is performed only once BEFORE page is loaded (after tombstoning it also needs to be loaded again)

advantages to put code in app.xaml.cs in wp7

I am wondering if there are any advantages to putting the code into app.xaml.cs (Application_Launching) compared to the code I've put into the mainpage.xaml.cs (MainPage()) section.
The key thing to bear in mind is that the Application object in App.xaml.cs is where you get notification of the application lifecycle events.
See Execution Model for Windows Phone on MSDN for more information about this.
By using the Launching/Activated methods on your Application object, you can make sure you are initialising your whole app correctly when it starts or is resumed after tombstoning (or returns from the dormant state in WP7 Mango).
Code in your startup page (MainPage.xaml.cs) is used to initialize that one application page when it is navigated to. This is typically done in the OnNavigatedTo method as you can't rely on pages being freshly constructed every time you navigate to them.
Of course you will also need to handle the other events for application exit and deactivation, and navigation away from each of your pages.
Also bear in mind that if you are targeting WP7 Mango, you can start the app from a deep link in an alarm, reminder or toast to a page other than your normal startup page. If the application starts like this, code in your startup page MainPage.xaml.cs may not run, but code in your Application object always would.

New Instance of the page on Navigation

I have a few pages in an Application that require A-Synchronous calls to be made for about 2-3 minutes to get Synchronized, the user may navigate away from that page during Synchronization and can come back again after visiting multiple pages and the sync continues all the time he is on other pages as well, when I go to a page from sync-page and press the Back button everything works fine.. but when i go to a page and navigate back to sync-page from Application Bar a new Instance of the Page is created and the Sync is just like Re-started.
Now i know every thing is working fine since new instance of a page is created when i call NavigationService.Navigate() , but what should i do in this scenario ? How to get the old instance of a page if it is there ?
Thanks...
You can't get an "old" instance of a page and it's not guaranteed that a backwards navigation will reload the previous instance of the page, it may be a new instance of the same page, but restored to the same state (assuming you saved any).
If you are trying to provide backwards navigation from the application bar then a) you probably shouldn't because that's what the back button is for, and b) you should make sure you use NavigationService.GoBack() instead of NavigationService.Navigate() because Navigate will always launch a new instance of your page.
If the page you want to get to is not the previous page, then it sounds like you are trying to implement non-linear navigation for which there is a recipe on the App Hub.
By the sounds of your scenario, you should handle this long running process separately (away from the view) and then display it's progress or results in a view when the user navigates to the relevant page.

Resources