InputBindings work only when focused

前端 未结 5 1967
旧时难觅i
旧时难觅i 2020-12-03 03:39

I have designed a reuseable usercontrol. It contains UserControl.InputBindings. It is quite simple as it only contains a label and a button (and new properties etc.)

5条回答
  •  青春惊慌失措
    2020-12-03 04:17

    Yet a bit late and possibly not 100% MVVM conform, one can use the following onloaded-event to propagate all Inputbindings to the window.

    void UserControl1_Loaded(object sender, RoutedEventArgs e)
        {
            Window window = Window.GetWindow(this);
            foreach (InputBinding ib in this.InputBindings)
            {
                window.InputBindings.Add(ib);
            }
        }
    

    Since this only affects the View-Layer I would be fine with this solution in terms of MVVM. found this bit here

提交回复
热议问题