3

I'm using the Extended WPF Toolkit's Zoombox. Right now, Ctrl + drag and drop is changing the position, and alt + Scroll is changing the zoom. Logically I'd rather have this turned around since in most software Ctrl+Scroll is used for zooming. How do I change these keys? I played around with DragModifiers and RelativeZoomModifiers property but can't get it to work.

I tried the following:

<xctk:Zoombox Margin="20" ClipToBounds="False" HorizontalAlignment="Stretch" Name="CanvasZoombox" VerticalAlignment="Stretch" Scale="1" AutoWrapContentWithViewbox="False">
    <xctk:Zoombox.ZoomModifiers>
        <xctk:KeyModifier>LeftCtrl</xctk:KeyModifier>
    </xctk:Zoombox.ZoomModifiers>
    <xctk:Zoombox.RelativeZoomModifiers>
        <xctk:KeyModifier>LeftCtrl</xctk:KeyModifier>
    </xctk:Zoombox.RelativeZoomModifiers>

    <Viewbox Stretch="Uniform" Name="CanvasViewbox" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" OpacityMask="White">
        <Canvas  Name="LabelCanvas" Background="#FFC3C3C3"/>
    </Viewbox>
</xctk:Zoombox>

This doesn't change anything unfortunately

Markinson
  • 2,077
  • 4
  • 28
  • 56

1 Answers1

3

Since you dont stated, why you didnt got it to work, here an Code-Behind-Example:

  var zoomKeys = new KeyModifierCollection();
  zoomKeys.Add(KeyModifier.Ctrl);
  zoomKeys.Add(KeyModifier.Exact);
  var dragKeys = new KeyModifierCollection();
  dragKeys.Add(KeyModifier.Alt);
  dragKeys.Add(KeyModifier.Exact);
  this.zoombox.ZoomModifiers = zoomKeys;
  this.zoombox.DragModifiers = dragKeys;

Since these Modifiers are all DependencyProperties, you can also bind them in the MVVM-fashioned way.

Update

The XAML-way

<xctk:Zoombox.ZoomModifiers>
      <xctk:KeyModifierCollection>
            <xctk:KeyModifier>Ctrl</xctk:KeyModifier>
            <xctk:KeyModifier>Exact</xctk:KeyModifier>
       </xctk:KeyModifierCollection>
 </xctk:Zoombox.ZoomModifiers>
 <xctk:Zoombox.DragModifiers>
       <xctk:KeyModifierCollection>
             <xctk:KeyModifier>Alt</xctk:KeyModifier>
             <xctk:KeyModifier>Exact</xctk:KeyModifier>
       </xctk:KeyModifierCollection>
 </xctk:Zoombox.DragModifiers>

The trick is to wrap the KeyModifier in its suiting collection KeyModifierCollection

lokusking
  • 7,396
  • 13
  • 38
  • 57
  • I did a post update, my apologies for not mentioning what doesn't work in the first place. Maybe that'll help for your answer? Your answer will work too but a XAML answer would be better I think! (thanks for your help so far) – Markinson Oct 25 '16 at 11:01
  • @Derp Updated Answer – lokusking Oct 25 '16 at 11:15