title: Set a border on a datagrid row
body: <p>I've the following styles for my datagrid rows and cells :</p>
  
  <pre><code>&lt;Style TargetType="{x:Type DataGridRow}"&gt;
              &lt;Setter Property="Margin" Value="0"/&gt;
              &lt;Setter Property="BorderBrush" Value="Transparent" /&gt;
              &lt;Setter Property="HorizontalAlignment" Value="Stretch" /&gt;
              &lt;Setter Property="Foreground" Value="{StaticResource ResourceKey=CouleurTexte}" /&gt;
              &lt;Setter Property="Padding" Value="0"/&gt;
              &lt;Setter Property="BorderThickness" Value="1"/&gt;
              &lt;Setter Property="Cursor" Value="Arrow"/&gt;
              &lt;Style.Triggers&gt;
                  &lt;Trigger Property="IsSelected" Value="True"&gt;
                      &lt;Setter Property="Background" Value="{StaticResource ResourceKey=CouleurDataGridRowSelected}"/&gt;
                      &lt;Setter Property="Foreground" Value="{StaticResource ResourceKey=CouleurTexteBouton}" /&gt;
                      &lt;Setter Property="BorderBrush" Value="{StaticResource ResourceKey=CouleurDataGridBorderSelected}" /&gt;
                  &lt;/Trigger&gt;
                  &lt;Trigger Property="IsMouseOver" Value="True"&gt;
                      &lt;Setter Property="Background" Value="{StaticResource ResourceKey=CouleurDataGridRowHover}"/&gt;
                  &lt;/Trigger&gt;
              &lt;/Style.Triggers&gt;
          &lt;/Style&gt;
  &lt;Style TargetType="{x:Type DataGridCell}"&gt;
          &lt;Setter Property="Padding" Value="5" /&gt;
          &lt;Setter Property="BorderBrush" Value="Transparent" /&gt;
          &lt;Setter Property="FocusVisualStyle" Value="{x:Null}" /&gt;
          &lt;Setter Property="Cursor" Value="Arrow"/&gt;
          &lt;Setter Property="BorderThickness" Value="0"/&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="{x:Type DataGridCell}"&gt;
                      &lt;Border Padding="{TemplateBinding Padding}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True"&gt;
                          &lt;ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"&gt;
                              &lt;ContentPresenter.ContentTemplate&gt;
                                  &lt;DataTemplate&gt;
                                      &lt;TextBlock Background="Transparent" Name="texte" TextTrimming="CharacterEllipsis" 
                                  Height="auto" Width="auto" VerticalAlignment="Center" Text="{Binding Text}"/&gt;
                                  &lt;/DataTemplate&gt;
                              &lt;/ContentPresenter.ContentTemplate&gt;
                          &lt;/ContentPresenter&gt;
                      &lt;/Border&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
          &lt;Style.Triggers&gt;
              &lt;Trigger Property="IsSelected" Value="True"&gt;
                  &lt;Setter Property="Background" Value="{StaticResource ResourceKey=CouleurDataGridRowSelected}"/&gt;
              &lt;/Trigger&gt;
              &lt;DataTrigger Binding="{Binding Path=IsMouseOver, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}" Value="True"&gt;
              &lt;/DataTrigger&gt;
          &lt;/Style.Triggers&gt;
      &lt;/Style&gt;
  </code></pre>
  
  <p>with my datagrid defined with stars in the width of my columns (so they can take all the space of the window).</p>
  
  <p>I want to set a border around a full row when its selected. My styles work fine until I set BorderThickness to 1 in the datagrid row.
  When I do the datagrid show the horizontal scrollbar to scroll only one (maybe 2) pixel (the one from the border added).
  When I don't have all my columns with "<em>" as width it works fine but I need to find a way to make it work with "</em>". How can I avoid this behavior ? It seems the border come on the outside of the row ?</p>
  
  <p>Thank you</p>