mvvm - WPF InputBinding in UserControl doesent work until focused -


I have the main view (window) as a shell in which I have different "pages" or "views" Users loading the userstrokes Navigate the application

I change the view by setting a view model on a content property on the menu. A DataTemplate selects the correct view based on ViewModel.

I want to use an F1 keyboard shortcut to trigger the command on current UserControl.

If I add inputbidding to UserControl I will have to select something in UserControl before I can kill F1.

If I add inputbidding to the window then I do not have the right datacontext (viewodal). I have also tried to set up CommandTarget in the contents property of ViewModel

  & lt; Window.InputBindings & gt; & Lt; Keying key = "F1" CommandTarget = "{binding element name = content control}" command = "{binding show info comand}" /> & Lt; /Window.InputBindings> I have also tried setting the focus manager. FocusAlment = "{binding element name = content control}" on main window and focus on the appropriate = User control and even content control.   

I got a good solution from here, to promote keybinding from user control to window Using behavior

I've found that if you have generic content in the template generic. If you are using behavior in XML then you do not have template paper templateBinding

  & lt; Frontline behavior: InputBindingBehavior.PropagateInputBindingsToWindow = "True" & gt; & Lt; Border.InputBindings & gt; & Lt; Keybaying key = "F1" command = "{binding relative Soros = {reslevsource template}, path = show info comand}" /> & Lt; /Border.InputBindings> & Lt; / Border & gt;  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -