title: How to set margin for scrollbar in scrollviewer using xaml only
body: <p>I need set the scrollbar's margin in a scrollviewer.
  I try to rewrite scrollbar margin in default scrollviewer style. just modify the margin in the style, and the scrollbar magin set the right value. But the content in scrollviewer just stay static when the scrollbar move. How can I fixed it or is there another way to set the margin for scrollbar in scrollviewer easier? </p>
  
  <pre><code>&lt;Style TargetType="ScrollViewer"&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="1"/&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}"
                          `enter code here`         Maximum="{TemplateBinding ScrollableHeight}"
                                   Minimum="0"
                                   Value="{TemplateBinding VerticalOffset}"
                                   Margin="0,20,0,0"/&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"/&gt;
  
                    &lt;/Grid&gt;
                &lt;/Border&gt;
            &lt;/ControlTemplate&gt;
        &lt;/Setter.Value&gt;
    &lt;/Setter&gt;
  </code></pre>
  
  <p></p>