title: Zoom Control which is part of WPF Extensions available on Codeplex
body: <p>The zoom control found at <a href="http://wpfextensions.codeplex.com/" rel="nofollow">http://wpfextensions.codeplex.com/</a> is something that I would like to use in my project.  However, there is one feature I wish it had.  I would like for it to work with a ScrollViewer so that if the contents are zoomed in, the scrollbars would activate (if necessary).</p>
  
  <p>The control's template is defined in Generic.xaml:</p>
  
  <pre><code>&lt;Style TargetType="{x:Type Controls:ZoomControl}"&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="{x:Type Controls:ZoomControl}"&gt;
                      &lt;Grid&gt;
                          &lt;Border BorderBrush="{TemplateBinding BorderBrush}"                                
                              BorderThickness="{TemplateBinding BorderThickness}"
                                  Background="Green"
                                  ClipToBounds="{TemplateBinding ClipToBounds}"&gt;
                              &lt;Controls:ZoomContentPresenter x:Name="PART_Presenter"
                                                             ClipToBounds="False" /&gt;
                          &lt;/Border&gt;
                          &lt;Canvas&gt;
  
                              &lt;!-- Controls --&gt;
                              &lt;Border Padding="5"
                                      CornerRadius="5"
                                      Background="#88C0C0C0"
                                      Canvas.Left="20"
                                      Canvas.Top="20"
                                      ToolTipService.InitialShowDelay="0"&gt;
                                  &lt;Border.ToolTip&gt;
                                      &lt;StackPanel Orientation="Vertical"&gt;
                                          &lt;TextBlock&gt;&lt;Run FontWeight="Bold"&gt;CTRL + Wheel:&lt;/Run&gt; Zoom In / Out&lt;/TextBlock&gt;
                                          &lt;TextBlock&gt;&lt;Run FontWeight="Bold"&gt;ALT + Drag:&lt;/Run&gt; ZoomBox&lt;/TextBlock&gt;
                                          &lt;TextBlock&gt;&lt;Run FontWeight="Bold"&gt;(SHIFT +) Drag:&lt;/Run&gt; Pan&lt;/TextBlock&gt;
                                      &lt;/StackPanel&gt;
                                  &lt;/Border.ToolTip&gt;
                                  &lt;StackPanel Orientation="Vertical"&gt;
                                      &lt;StackPanel.Resources&gt;
                                          &lt;Style TargetType="{x:Type RadioButton}"&gt;
                                              &lt;Setter Property="Template"&gt;
                                                  &lt;Setter.Value&gt;
                                                      &lt;ControlTemplate TargetType="{x:Type RadioButton}"&gt;
                                                          &lt;Border x:Name="border"
                                                                  BorderBrush="Black"
                                                                  Background="Silver"
                                                                  BorderThickness="1"
                                                                  CornerRadius="5"
                                                                  Width="40"
                                                                  Height="40"
                                                                  Margin="2"
                                                                  HorizontalAlignment="Center"
                                                                  VerticalAlignment="Center"&gt;
                                                              &lt;ContentPresenter HorizontalAlignment="Center"
                                                                                VerticalAlignment="Center" /&gt;
                                                          &lt;/Border&gt;
  
                                                          &lt;ControlTemplate.Triggers&gt;
                                                              &lt;Trigger Property="IsMouseOver"
                                                                       Value="True"&gt;
                                                                  &lt;Setter TargetName="border"
                                                                          Property="Background"
                                                                          Value="WhiteSmoke" /&gt;
                                                              &lt;/Trigger&gt;
                                                              &lt;Trigger Property="IsChecked"
                                                                       Value="True"&gt;
                                                                  &lt;Setter TargetName="border"
                                                                          Property="Background"
                                                                          Value="DarkGray" /&gt;
                                                                  &lt;Setter TargetName="border"
                                                                          Property="TextBlock.FontWeight"
                                                                          Value="Bold" /&gt;
                                                              &lt;/Trigger&gt;
                                                          &lt;/ControlTemplate.Triggers&gt;
                                                      &lt;/ControlTemplate&gt;
                                                  &lt;/Setter.Value&gt;
                                              &lt;/Setter&gt;
                                          &lt;/Style&gt;
                                      &lt;/StackPanel.Resources&gt;
                                      &lt;Slider Height="150"
                                              Minimum="{TemplateBinding MinZoom,Converter={StaticResource log10Converter}}"
                                              Maximum="{TemplateBinding MaxZoom,Converter={StaticResource log10Converter}}"
                                              Value="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Zoom,Mode=TwoWay,Converter={StaticResource log10Converter}}"
                                              HorizontalAlignment="Center"
                                              Ticks="0.1, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 2"
                                              AutoToolTipPlacement="BottomRight"
                                              AutoToolTipPrecision="1"
                                              TickPlacement="BottomRight"
                                              TickFrequency="1"
                                              LargeChange="1"
                                              SmallChange="0.1"
                                              Orientation="Vertical" /&gt;
                                      &lt;TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Zoom,StringFormat='{}{0:F2}x'}"
                                                 HorizontalAlignment="Center"
                                                 FontWeight="Bold" /&gt;
                                      &lt;RadioButton Content="1:1"
                                                   GroupName="rbgZoomMode"
                                                   IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Mode,Converter={StaticResource equalityConverter},ConverterParameter={x:Static Controls:ZoomControlModes.Original}}" /&gt;
                                      &lt;RadioButton Content="Fill"
                                                   GroupName="rbgZoomMode"
                                                   IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Mode,Converter={StaticResource equalityConverter},ConverterParameter={x:Static Controls:ZoomControlModes.Fill}}" /&gt;
                                  &lt;/StackPanel&gt;
                              &lt;/Border&gt;
  
                              &lt;!-- ZoomBox --&gt;
                              &lt;Border BorderBrush="{TemplateBinding ZoomBoxBorderBrush}"
                                      BorderThickness="{TemplateBinding ZoomBoxBorderThickness}"
                                      Canvas.Left="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ZoomBox.X}"
                                      Canvas.Top="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ZoomBox.Y}"
                                      Opacity="{TemplateBinding ZoomBoxOpacity}"
                                      Background="{TemplateBinding ZoomBoxBackground}"
                                      Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ZoomBox.Width}"
                                      Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ZoomBox.Height}" /&gt;
                          &lt;/Canvas&gt;
                      &lt;/Grid&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
          &lt;Setter Property="Background"
                  Value="White" /&gt;
          &lt;Setter Property="ZoomBoxBackground"&gt;
              &lt;Setter.Value&gt;
                  &lt;LinearGradientBrush StartPoint="0.0, 0.0"
                                       EndPoint="1.0, 1.0"&gt;
                      &lt;GradientStop Color="Silver"
                                    Offset="0.0" /&gt;
                      &lt;GradientStop Color="DarkGray"
                                    Offset="1.0" /&gt;
                  &lt;/LinearGradientBrush&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
          &lt;Setter Property="ZoomBoxBorderBrush"
                  Value="Black" /&gt;
          &lt;Setter Property="ZoomBoxBorderThickness"
                  Value="1" /&gt;
          &lt;Setter Property="ClipToBounds"
                  Value="True" /&gt;
          &lt;Style.Triggers&gt;
              &lt;Trigger Property="ModifierMode"
                       Value="Pan"&gt;
                  &lt;Setter Property="Cursor"
                          Value="SizeAll" /&gt;
              &lt;/Trigger&gt;
              &lt;Trigger Property="ModifierMode"
                       Value="ZoomBox"&gt;
                  &lt;Setter Property="Cursor"
                          Value="Hand" /&gt;
              &lt;/Trigger&gt;
          &lt;/Style.Triggers&gt;
      &lt;/Style&gt;
  </code></pre>
  
  <p>I tried adding ScrollViewer tags around the PART_Presenter but that caused the control to break (nothing was rendered).</p>
  
  <p>Hopefully someone smarter than I am can help me out with this.  The control is not that complex but I am still learning WPF and especially templating.</p>
  
  <p>Thanks a lot.</p>