2

I have a small application that uses a navigation window and a set of pages. My application is not a browser per se and thus I dont want the user to be able to refresh the page by pressing F5. Is there a way to disable this key in my application? Many thanks all.

Edgar
  • 39
  • 2
  • 7

2 Answers2

5

You could disable refreshing altogether, by attaching a handler to the Navigating event:

yourNavigationWindow.Navigating += OnNavigating;

// ...

void OnNavigating(object sender, NavigatingCancelEventArgs e)
{
    if(e.NavigationMode == NavigationMode.Refresh)
        e.Cancel = true;
}        
Jens
  • 25,229
  • 9
  • 75
  • 117
  • Both solutions are good. I'll go for Jens though. Thanks to both. This works now! Edgar – Edgar Feb 22 '11 at 16:11
1

You can try to remove the CommandBinding from the NavigationWindow. NavigationCommand.Refresh

Something like:

CommandBinding removeBinding=null;
foreach(CommandBinding cb in navigationWindow.CommandBindings){
 if(cb.Command==NavigationCommand.Refresh){
   removeBinding=cb;
   break;
 }
 if(removeBinding != null){
   navigationWindow.CommandBindings.Remove(removeBinding);
 }

}
PeterB
  • 151
  • 3