title: In WPF, how to customize the style of ScrollBar in ScrollViewer
body: <p>I can add a ScrollBar style as global. But that will alse change all the ScrollBar except in ScrollViewer.
  How can I just change the style of ScrollBar in ScrollViewer. Maybe add a style with a Key and specify it to somewhere like a ControlTemplate.</p>
  
  <p>Here is my fully ScrollBar style:</p>
  
  <pre><code>&lt;Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}"&gt;
      &lt;Setter Property="OverridesDefaultStyle" Value="true"/&gt;
      &lt;Setter Property="IsTabStop" Value="false"/&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="{x:Type Thumb}"&gt;
                  &lt;Border x:Name="rectangle"
                              SnapsToDevicePixels="True"
                              Background="{StaticResource WordBlueBrush}"
                              Opacity="0.3"
                              CornerRadius="4"
                              Height="{TemplateBinding Height}"
                              Width="{TemplateBinding Width}"/&gt;   
                  &lt;ControlTemplate.Triggers&gt;
                      &lt;Trigger Property="IsMouseOver" Value="true"&gt;
                          &lt;Setter TargetName="rectangle" Property="Opacity" Value="1" /&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}"&gt;
      &lt;Setter Property="Stylus.IsPressAndHoldEnabled" Value="false"/&gt;
      &lt;Setter Property="Stylus.IsFlicksEnabled" Value="false"/&gt;
  
      &lt;Setter Property="Width" Value="14"/&gt;
      &lt;Setter Property="Margin" Value="-14 0 0 0" /&gt;
      &lt;Setter Property="MinWidth" Value="{Binding Height, RelativeSource={RelativeSource Self}}"/&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="{x:Type ScrollBar}"&gt;
                  &lt;Grid x:Name="Bg" SnapsToDevicePixels="true"&gt;
  
                      &lt;Border Padding="0 4"&gt;
                          &lt;Track x:Name="PART_Track"
                          IsDirectionReversed="true"
                          IsEnabled="{TemplateBinding IsMouseOver}"
                          Width="8"
                          HorizontalAlignment="Center"
                             &gt;
                              &lt;Track.DecreaseRepeatButton&gt;
                                  &lt;RepeatButton Opacity="0" Command="{x:Static ScrollBar.PageUpCommand}" /&gt;
                              &lt;/Track.DecreaseRepeatButton&gt;
                              &lt;Track.IncreaseRepeatButton&gt;
                                  &lt;RepeatButton Opacity="0" Command="{x:Static ScrollBar.PageDownCommand}" /&gt;
                              &lt;/Track.IncreaseRepeatButton&gt;
                              &lt;Track.Thumb&gt;
                                  &lt;Thumb Style="{StaticResource ScrollBarThumb  }" /&gt;
                              &lt;/Track.Thumb&gt;
                          &lt;/Track&gt;
                      &lt;/Border&gt;
                  &lt;/Grid&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>