title: ScrollViewer with custom style doesn't scroll when dragged
body: <p>I'm not an expert in WPF, but I found a style online for OS X-like scrollbars. It looks fine, and does scroll in the expected way with the mouse wheel, but oddly, if you drag the scroll bar with the mouse, it doesn't actually scroll the content, it just moves the bar on the screen. What is wrong with this style? </p>
  
  <p>I won't pretend I completely understand everything that's going on in this style, but I've been looking into the documentation for the individual pieces of it, and I cannot, thus far, figure out what's wrong.</p>
  
  <p>XAML: </p>
  
  <pre><code>&lt;Style x:Key="ScrollBarTrackThumb"
          TargetType="{x:Type Thumb}"&gt;
                  &lt;Setter Property="Template"&gt;
                      &lt;Setter.Value&gt;
                          &lt;ControlTemplate TargetType="{x:Type Thumb}"&gt;
                              &lt;Grid x:Name="Grid"&gt;
                                  &lt;Rectangle HorizontalAlignment="Stretch"
                                  VerticalAlignment="Stretch"
                                  Width="Auto"
                                  Height="Auto"
                                  Fill="Transparent" /&gt;
                                  &lt;Border x:Name="CornerScrollBarRectangle"
                              CornerRadius="5"
                              HorizontalAlignment="Stretch"
                              VerticalAlignment="Stretch"
                              Width="Auto"
                              Height="Auto"
                              Margin="0,1,0,1"
                              Background="{TemplateBinding Background}" /&gt;
                              &lt;/Grid&gt;
                              &lt;ControlTemplate.Triggers&gt;
                                  &lt;Trigger Property="Tag"
                                  Value="Horizontal"&gt;
                                      &lt;Setter TargetName="CornerScrollBarRectangle"
                                  Property="Width"
                                  Value="Auto" /&gt;
                                      &lt;Setter TargetName="CornerScrollBarRectangle"
                                  Property="Height"
                                  Value="6" /&gt;
                                  &lt;/Trigger&gt;
                              &lt;/ControlTemplate.Triggers&gt;
                          &lt;/ControlTemplate&gt;
                      &lt;/Setter.Value&gt;
                  &lt;/Setter&gt;
              &lt;/Style&gt;
              &lt;Style TargetType="{x:Type ScrollBar}" x:Key="BlackBGScrollBar"&gt;
                  &lt;Setter Property="Stylus.IsFlicksEnabled"
              Value="false" /&gt;
                  &lt;Setter Property="Foreground"
              Value="#ADABAB" /&gt;
                  &lt;Setter Property="Background"
              Value="Transparent" /&gt;
                  &lt;Setter Property="Width"
              Value="7" /&gt;
                  &lt;Setter Property="Template"&gt;
                      &lt;Setter.Value&gt;
                          &lt;ControlTemplate TargetType="{x:Type ScrollBar}"&gt;
                              &lt;Grid x:Name="GridRoot"
                          Width="7"
                          Background="{TemplateBinding Background}"&gt;
                                  &lt;Grid.RowDefinitions&gt;
                                      &lt;RowDefinition Height="0.00001*" /&gt;
                                  &lt;/Grid.RowDefinitions&gt;
                                  &lt;Track x:Name="PART_Track"
                              Grid.Row="0"
                              IsDirectionReversed="true"
                              Focusable="false"&gt;
                                      &lt;Track.Thumb&gt;
                                          &lt;Thumb x:Name="Thumb"
                                      Background="{TemplateBinding Foreground}"
                                      Style="{DynamicResource ScrollBarTrackThumb}" /&gt;
                                      &lt;/Track.Thumb&gt;
                                      &lt;Track.IncreaseRepeatButton&gt;
                                          &lt;RepeatButton x:Name="PageUp"
                                              Command="ScrollBar.PageDownCommand"
                                              Opacity="0"
                                              Focusable="false" /&gt;
                                      &lt;/Track.IncreaseRepeatButton&gt;
                                      &lt;Track.DecreaseRepeatButton&gt;
                                          &lt;RepeatButton x:Name="PageDown"
                                              Command="ScrollBar.PageUpCommand"
                                              Opacity="0"
                                              Focusable="false" /&gt;
                                      &lt;/Track.DecreaseRepeatButton&gt;
                                  &lt;/Track&gt;
                              &lt;/Grid&gt;
                              &lt;ControlTemplate.Triggers&gt;
                                  &lt;Trigger SourceName="Thumb"
                                  Property="IsMouseOver"
                                  Value="true"&gt;
                                      &lt;Setter Value="{DynamicResource ButtonSelectBrush}"
                                  TargetName="Thumb"
                                  Property="Background" /&gt;
                                  &lt;/Trigger&gt;
                                  &lt;Trigger SourceName="Thumb"
                                  Property="IsDragging"
                                  Value="true"&gt;
                                      &lt;Setter Value="{DynamicResource DarkBrush}"
                                  TargetName="Thumb"
                                  Property="Background" /&gt;
                                  &lt;/Trigger&gt;
  
                                  &lt;Trigger Property="IsEnabled"
                                  Value="false"&gt;
                                      &lt;Setter TargetName="Thumb"
                                  Property="Visibility"
                                  Value="Collapsed" /&gt;
                                  &lt;/Trigger&gt;
                                  &lt;Trigger Property="Orientation"
                                  Value="Horizontal"&gt;
                                      &lt;Setter TargetName="GridRoot"
                                  Property="LayoutTransform"&gt;
                                          &lt;Setter.Value&gt;
                                              &lt;RotateTransform Angle="-90" /&gt;
                                          &lt;/Setter.Value&gt;
                                      &lt;/Setter&gt;
                                      &lt;Setter TargetName="PART_Track"
                                  Property="LayoutTransform"&gt;
                                          &lt;Setter.Value&gt;
                                              &lt;RotateTransform Angle="-90" /&gt;
                                          &lt;/Setter.Value&gt;
                                      &lt;/Setter&gt;
                                      &lt;Setter Property="Width"
                                  Value="Auto" /&gt;
                                      &lt;Setter Property="Height"
                                  Value="8" /&gt;
                                      &lt;Setter TargetName="Thumb"
                                  Property="Tag"
                                  Value="Horizontal" /&gt;
                                      &lt;Setter TargetName="PageDown"
                                  Property="Command"
                                  Value="ScrollBar.PageLeftCommand" /&gt;
                                      &lt;Setter TargetName="PageUp"
                                  Property="Command"
                                  Value="ScrollBar.PageRightCommand" /&gt;
                                  &lt;/Trigger&gt;
                              &lt;/ControlTemplate.Triggers&gt;
                          &lt;/ControlTemplate&gt;
                      &lt;/Setter.Value&gt;
                  &lt;/Setter&gt;
              &lt;/Style&gt;
  
              &lt;Style TargetType="ScrollViewer" x:Key="BlackBGScrollViewer"&gt;
                  &lt;Setter Property="HorizontalContentAlignment" Value="Left" /&gt;
                  &lt;Setter Property="VerticalContentAlignment" Value="Top" /&gt;
                  &lt;Setter Property="VerticalScrollBarVisibility" Value="Visible" /&gt;
                  &lt;Setter Property="Padding" Value="4"/&gt;
                  &lt;Setter Property="BorderThickness" Value="0"/&gt;
                  &lt;Setter Property="BorderBrush"&gt;
                      &lt;Setter.Value&gt;
                          &lt;LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"&gt;
                              &lt;GradientStop Color="#FFA3AEB9" Offset="0"/&gt;
                              &lt;GradientStop Color="#FF8399A9" Offset="0.375"/&gt;
                              &lt;GradientStop Color="#FF718597" Offset="0.375"/&gt;
                              &lt;GradientStop Color="#FF617584" Offset="1"/&gt;
                          &lt;/LinearGradientBrush&gt;
                      &lt;/Setter.Value&gt;
                  &lt;/Setter&gt;
                  &lt;Setter Property="Template"&gt;
                      &lt;Setter.Value&gt;
                          &lt;ControlTemplate TargetType="ScrollViewer"&gt;
                              &lt;Border CornerRadius="2" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"&gt;
                                  &lt;Grid Background="{TemplateBinding Background}"&gt;
                                      &lt;Grid.RowDefinitions&gt;
                                          &lt;RowDefinition Height="*"/&gt;
                                          &lt;RowDefinition Height="Auto"/&gt;
                                      &lt;/Grid.RowDefinitions&gt;
                                      &lt;Grid.ColumnDefinitions&gt;
                                          &lt;ColumnDefinition Width="*"/&gt;
                                          &lt;ColumnDefinition Width="Auto"/&gt;
                                      &lt;/Grid.ColumnDefinitions&gt;
  
                                      &lt;ScrollContentPresenter x:Name="ScrollContentPresenter"
                                                    Cursor="{TemplateBinding Cursor}"
                                                    Margin="{TemplateBinding Padding}"
                                                    ContentTemplate="{TemplateBinding ContentTemplate}"/&gt;
  
                                      &lt;Rectangle Grid.Column="1" Grid.Row="1" Fill="#FFE9EEF4"/&gt;
  
                                      &lt;ScrollBar x:Name="VerticalScrollBar" Width="18"
                                       IsTabStop="False"
                                       Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                                       Grid.Column="1" Grid.Row="0" Orientation="Vertical"
                                       ViewportSize="{TemplateBinding ViewportHeight}"
                                       Maximum="{TemplateBinding ScrollableHeight}"
                                       Minimum="0"
                                       Value="{TemplateBinding VerticalOffset}"
                                       Margin="0,-1,-1,-1"
                                       Style="{StaticResource BlackBGScrollBar}"/&gt;
  
                                      &lt;ScrollBar x:Name="HorizontalScrollBar" Height="18"
                                       IsTabStop="False"
                                       Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                                       Grid.Column="0" Grid.Row="1" Orientation="Horizontal"
                                       ViewportSize="{TemplateBinding ViewportWidth}"
                                       Maximum="{TemplateBinding ScrollableWidth}"
                                       Minimum="0"
                                       Value="{TemplateBinding HorizontalOffset}"
                                       Margin="-1,0,-1,-1"
                                       Style="{StaticResource BlackBGScrollBar}"/&gt;
  
                                  &lt;/Grid&gt;
                              &lt;/Border&gt;
                          &lt;/ControlTemplate&gt;
                      &lt;/Setter.Value&gt;
                  &lt;/Setter&gt;
              &lt;/Style&gt;
  </code></pre>