title: Touch scrolling DocumentViewer
body: <p>I'm using .NET 3.5, so I don't have all of the nice touch screen goodness.  I created my own touch screen <code>ScrollViewer</code> that works alright.  I'm wanting to incorporate that into the <code>DocumentViewer</code> template, but its not working.  Here is my variation of the template:</p>
  
  <pre><code>&lt;Style TargetType="{x:Type DocumentViewer}"&gt;
      &lt;Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}" /&gt;
      &lt;Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" /&gt;
      &lt;Setter Property="FocusVisualStyle" Value="{x:Null}" /&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="{x:Type DocumentViewer}"&gt;
                  &lt;Border BorderThickness="{TemplateBinding BorderThickness}" 
                          BorderBrush="{TemplateBinding BorderBrush}"
                          Focusable="False"&gt;
                      &lt;Grid KeyboardNavigation.TabNavigation="Local"&gt;
                          &lt;Grid.Background&gt;
                              &lt;SolidColorBrush Color="{DynamicResource ControlLightColor}" /&gt;
                          &lt;/Grid.Background&gt;
                          &lt;Grid.RowDefinitions&gt;
                              &lt;RowDefinition Height="Auto" /&gt;
                              &lt;RowDefinition Height="*" /&gt;
                              &lt;RowDefinition Height="Auto" /&gt;
                          &lt;/Grid.RowDefinitions&gt;
                          &lt;ToolBar ToolBarTray.IsLocked="True"
                                   KeyboardNavigation.TabNavigation="Continue"
                                   Visibility="Collapsed"&gt;
                              &lt;Button Command="ApplicationCommands.Print"
                                      CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                      Content="Print" /&gt;
                              &lt;Button Command="ApplicationCommands.Copy"
                                      CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                      Content="Copy" /&gt;
                              &lt;Separator /&gt;
                              &lt;Button Command="NavigationCommands.IncreaseZoom"
                                      CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                      Content="Zoom In" /&gt;
                              &lt;Button Command="NavigationCommands.DecreaseZoom"
                                      CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                      Content="Zoom Out" /&gt;
                              &lt;Separator /&gt;
                              &lt;Button Command="NavigationCommands.Zoom"
                                      CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                      CommandParameter="100.0"
                                      Content="Actual Size" /&gt;
                              &lt;Button Command="DocumentViewer.FitToWidthCommand"
                                      CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                      Content="Fit to Width" /&gt;
                              &lt;Button Command="DocumentViewer.FitToMaxPagesAcrossCommand"
                                      CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                      CommandParameter="1"
                                      Content="Whole Page" /&gt;
                              &lt;Button Command="DocumentViewer.FitToMaxPagesAcrossCommand"
                                      CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                      CommandParameter="2"
                                      Content="Two Pages" /&gt;
                          &lt;/ToolBar&gt;
  
                          &lt;custom:TouchScrollViewer x:Name="PART_ContentHost"
                                        Grid.Row="1"&gt;
                              &lt;ScrollViewer.Background&gt;
                                  &lt;LinearGradientBrush EndPoint="0.5,1"
                                                       StartPoint="0.5,0"&gt;
                                      &lt;GradientStop Color="{DynamicResource ControlLightColor}"
                                                    Offset="0" /&gt;
                                      &lt;GradientStop Color="{DynamicResource ControlMediumColor}"
                                                    Offset="1" /&gt;
                                  &lt;/LinearGradientBrush&gt;
                              &lt;/ScrollViewer.Background&gt;
                          &lt;/custom:TouchScrollViewer&gt;
  
                          &lt;ContentControl Grid.Row="2" x:Name="PART_FindToolBarHost" Visibility="Collapsed"/&gt;
                      &lt;/Grid&gt;
                  &lt;/Border&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>This doesn't work, because the act of moving your finger over the viewer just selects text.  The template is requires a <code>ScrollViewer</code> (or derivative thereof) with the name "PART_ContentHost".  Is there a way to lock a <code>ScrollViewer</code> to stretch to the extent of its contents.  I could then wrap my own <code>TouchScrollViewer</code> around the entire <code>DocumentViewer</code>.  Or is there a way to make the document viewer hit-test invisible (i.e <code>IsHItTestVisible = false</code>).  Thanks in advance. </p>