Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change keys Extended WPF Toolkit Zoombox

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

like image 627
Markinson Avatar asked Dec 19 '25 14:12

Markinson


1 Answers

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

like image 130
lokusking Avatar answered Dec 22 '25 04:12

lokusking



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!