1

Working on an older application from my predecessor which is using the first floor modern ui framework. Pretty much by accident we discovered, that the framework tries to refresh the current page when the user presses F5 key reinitializing the respective ViewModel. However, since there are several things triggered from the constructor, this leads to undefined behavior of the application. Additionally the application uses Oxyplot, which also leads to problems with data-binding between PlotView and PlotModel in the ViewModel.

What I have tried so far:

  • Looking through the source code of the framework so far I couldn't find, where the refresh is triggered, or how to prevent it.
  • I tried to assign the F5 key to another function, in this case as a shortcut to another page, like this:

    <mui:ModernWindow.InputBindings>
        <KeyBinding Command="{Binding Path=OpenManualCommand}" Key="F5 > 
       </KeyBinding>
    </mui:ModernWindow.InputBindings>
    
  • I found an issue on the github page of the framework, describing pretty much the problem I have. However, it didn't get any replies and being from 2016 it probably won't.

  • Using the KeyDown event and marking it as handled like this:

    private void UserControl_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.Key == Key.F5)
        {
            e.Handled = true;
        }
    }
    

    This actually works, however I would have to do the same operation for each view, since it doesn't work if I do it just from the MainWindow. Doesn't seem like a good solution to me.

Is there another way, which let me disable the function of the F5 key with this framework?

Roland Deschain
  • 2,211
  • 19
  • 50

1 Answers1

0

I managed to disable this using input binding and command. Command in ViewModel was calling a method by Relay which just had empty return statement in its body.

4b0
  • 21,981
  • 30
  • 95
  • 142