Where is InputBinder

Mar 4, 2010 at 9:26 AM

I am using InputBinder from your blog post WPF MVVM Helper Library (WPF + MVVM = testability), but had a problem getting the keybindings to show in the actual menu items. Thought to check if you had the same problem, but now the InputBinder has been removed from your framework. Has it changed name or did you think it was to no use?

 

Best regards.

Coordinator
Apr 13, 2010 at 5:23 PM
disore wrote:

I am using InputBinder from your blog post WPF MVVM Helper Library (WPF + MVVM = testability), but had a problem getting the keybindings to show in the actual menu items. Thought to check if you had the same problem, but now the InputBinder has been removed from your framework. Has it changed name or did you think it was to no use?

 

Best regards.

 Yes, it was removed, but not for any technical reason.  WPF4 is right around the corner and it supports {Binding} on input now directly.  So, I replaced InputBinder with a BindableCommand to make the leap from .NET 3.5 to 4.0 less intrusive on the code.  With BindableCommand, you place an instance in your resources:

<Window.Resouces>
    <BindableCommand x:Key="myCommand" Command="{Binding VMCommand}" />
</Window.Resources>

and then just use the resource in the normal WPF input binding collection:

<Window.InputBindings>
    <KeyBinding Key="A" Modifier="ALT" Command="{StaticResource myCommand}" />
</Window.InputBindings>

This approach will work with .NET4 as well, if you decide to change nothing when you port, alternatively, in .NET4 you will be able to drop the BindableCommand altogether and just do this:

<KeyBinding Key="A" Modifier="ALT" Command="{Binding VMCommand}" />

I hope that helps, sorry for the inconvenience! 

mark

Apr 14, 2010 at 7:06 AM

What great news! Didn't know binding on the input was a new feature in .NET4. BTW, there has been no inconvenience at all, instead your classes have been a great help, thanks.