locked
How to diffrentiate between is page being navigated from another page or by back button click

    Question

  • How to diffrentiate between is page being navigated from another page or by back button click

    I have page on Loaded I call a function or on Load State I call the function to load data.

    Scenario:

    1. Page 1 Loaded fire and data populated.
    2. CLick on any item Navigated to Page 2
    3. On CLick on back to Page 1 with Frame.GoBack()
    4. I don't want to call the load the data again, so How I will distinguish between them.
    5. AS both hold the navigation parameter

    Monday, June 16, 2014 5:51 AM

Answers

  • You can identify that from the NavigationEventArgs.NavigationMode parameter. 

    protected override void OnNavigatedTo(NavigationEventArgs e)
            {
                if (e.NavigationMode != Windows.UI.Xaml.Navigation.NavigationMode.Back)
                {
                    //TODO: Page can load its data
                }
            }

    - Ram
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Monday, June 16, 2014 6:36 AM

All replies

  • If you override the OnNavigateTo method in the page you can see what kind of action it was by using the Mode property.

    and othrer option would be to check if there is already data loaded in the view


    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Monday, June 16, 2014 6:31 AM
  • You can identify that from the NavigationEventArgs.NavigationMode parameter. 

    protected override void OnNavigatedTo(NavigationEventArgs e)
            {
                if (e.NavigationMode != Windows.UI.Xaml.Navigation.NavigationMode.Back)
                {
                    //TODO: Page can load its data
                }
            }

    - Ram
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Monday, June 16, 2014 6:36 AM