I want a refresh hotkey for my application, the standard key for "refresh" is F5 for most programs. So i would like to use that hotkey for my program aswell. The problem is that WPF uses F5 to refresh Frames.
I managed to turn off refresh on Frames with this in the codebehind for the usercontrol with the frame:
private void pageFrame_Navigating(object sender, System.Windows.Navigation.NavigatingCancelEventArgs e)
{
if (e.NavigationMode == NavigationMode.Refresh)
{
e.Cancel = true;
}
}
However, this still "catches" the keypress so that i cannot detect it else where in the program. It nullifies the key press as though it never happened. How can i stop Frame from refreshing when i press F5 and at the same time use F5 in other places?
I detect keypresses with:
public static void KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
switch (e.Key)
{
case Key.F6: //Send Group
//THIS HERE WORKS!
break;
case Key.F5: //Refresh Group
//THIS HERE DOES NOT WORK!
break;
}
}
This function is subscribed to the main window's "KeyDown" event.
For anyone finding this page with the same problem. I fixed it by using ContentControl instead of Frame and UserControl instead of Page.
I just used Frame and Page because of their names so i figured that was what you are supposed to do. But using ContentControl and UserControl instead gives you more freedom and there is nothing Frame/Page can do that ContentControl/UserControl cant be programmed to do.