Getting URL of current page in Windows Phone dynamically through code

Have you ever come across the requirement to fetch the URL of content current displaying on? Let us say there are 5 pages in your application and user is navigating across them. At any point of time if you want to fetch the URL of current page you can very much do that.

image

Above line of code will fetch URL of current page.

Imagine a scenario in which you need to fetch current page while deactivating the application. So you may do that as below,

 


private void Application_Deactivated(object sender, DeactivatedEventArgs e)
        {
            Uri currentUri = ((App)Application.Current).RootFrame.CurrentSource;


        }



This was all about getting the current page URL in Windows Phone application. I hope this quick post was useful. Thanks for reading Smile

2 responses to “Getting URL of current page in Windows Phone dynamically through code”

  1. This is too much. Being an MVP this doesn’t give your good impression to me. You mainly write posts not to share but to increase your popularity on no. of posts.

    Take my suggestion. Post once in a week with good content instead of posting multiple small notes daily. Also, I observed, you posted 3-4 posts daily which are really bogus. Instead of increasing no. of post count, try to give a single post with a good content.

    – Pallab R.

  2. […] Getting URL of current page in Windows Phone dynamically through code […]

Leave a comment

Create a website or blog at WordPress.com