0

Add additional InputBinding in XAML

Anonymous 6 years ago 0
This discussion was imported from CodePlex

govert wrote at 2012-03-28 14:21:

This is more a WPF / XAML questions, but arose in the Helix Toollkit context:

Earlier versions of the HelixView3D had both the Shift+RightClick and the MiddleClick bound to the Pan command. The default template in the current version sets the PanGesture to Shift+RightClick, but MiddleClick no longer works. I want to keep the Shift+RightClick, and add the MiddleClick as an additional gesture, which means I can't just set the PanGesture property (it would replace the current gesture).

From code-behind it works if I do this:

 

InitializeComponent();
sceneView3D.Loaded += delegate
    {
        sceneView3D.CameraController.InputBindings.Add(
            new InputBinding(CameraController.PanCommand,
                            new MouseGesture(MouseAction.MiddleClick)));
    };

 

But I'd rather set it in the XAML, so I've tried something like this:

<helix:HelixViewport3D x:Name="sceneView3D" ... >
  <helix:HelixViewport3D.InputBindings>
    <MouseBinding MouseAction="MiddleClick" Command="{x:Static helix:CameraController.PanCommand}"/>
  </helix:HelixViewport3D.InputBindings>
...
</helix:HelixViewport3D>

 

but it doesn't work - we need to add to the CameraController's InputBindings.

Is it possible to add the InputGesture from XAML?

Thanks for the help,
Govert 


objo wrote at 2012-04-03 01:20:

I added an alternative pan gesture dependency property (PanGesture2), and set the default value to the middle button.

That was the easy solution, not sure how to get the inputbindings to work..