Frage

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.

War es hilfreich?

Lösung

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;
}        

Andere Tipps

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);
 }

}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top