wpfrefreshxbap

How to stop reloading the page when the user press F5 or CTRL+R in XBAP Application


I have an XBAP Application.

In XBAP Page, if the user presses F5 or CTRL+R then the confirmation message must be shown to the user.

If Yes then the page must be reloded.

If No then the current page must remain as it is.

Can any one help how to do this.


Solution

  • You could call on NavigationMode of Navigating event parameter, like code below shows,

    Application.Current.Navigating += new NavigatingCancelEventHandler(Current_Navigating);
    
      void Current_Navigating(object sender, NavigatingCancelEventArgs e)
      {
       if (e.NavigationMode == NavigationMode.Refresh)
       {
        //put your logic here
       }
      }
    

    If user trigger refresh operation either by F5 or Ctrl+R combination keys, you could catch this event and handle it.