title: WPF - Listview Item Margin
body: <p>My Listview items are not stretching to the full width of the column. There is always a margin  on the right of my cell border. I would like to get the bordered area to stretch over the full column width and get rid of any padding, margins or anything else on the left and right of my content. The goal is to have the borders fill the whole space in each cell.</p>
  
  <p>I have already applied stretching and set the margins to "-6,0,-6,0" but that doesn't seem to solve the problem.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>  &lt;Grid&gt;
              &lt;Grid.Resources&gt;
                  &lt;x:Array Type="{x:Type sys:String}" x:Key="items"&gt;
                      &lt;sys:String&gt;Foo&lt;/sys:String&gt;
                      &lt;sys:String&gt;Bar&lt;/sys:String&gt;
                      &lt;sys:String&gt;Spong&lt;/sys:String&gt;
                  &lt;/x:Array&gt;
              &lt;/Grid.Resources&gt;
  
              &lt;ListView ItemsSource="{StaticResource items}"&gt;
  
                  &lt;ListView.ItemContainerStyle&gt;
                      &lt;Style TargetType="ListViewItem"&gt;
                          &lt;Setter Property="Margin"
              Value="-6, 0,-6,0" /&gt;
                          &lt;Setter Property="HorizontalAlignment" Value="Stretch" /&gt;
                          &lt;Setter Property="HorizontalContentAlignment" Value="Stretch" /&gt;
                          &lt;Setter Property="VerticalContentAlignment" Value="Stretch" /&gt;
                          &lt;Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/&gt;
                      &lt;/Style&gt;
                  &lt;/ListView.ItemContainerStyle&gt;
  
                  &lt;ListView.View&gt;
                      &lt;GridView&gt;
                          &lt;GridViewColumn Header="Data" Width="80"&gt;
                              &lt;GridViewColumn.CellTemplate&gt;
                                  &lt;DataTemplate&gt;
                                      &lt;Border BorderThickness="2" BorderBrush="Black" HorizontalAlignment="Stretch"&gt;
                                          &lt;TextBox Text="{Binding .}"  /&gt;
                                      &lt;/Border&gt;
  
                                  &lt;/DataTemplate&gt;
                              &lt;/GridViewColumn.CellTemplate&gt;
                          &lt;/GridViewColumn&gt;
                          &lt;GridViewColumn Header="Length"
           DisplayMemberBinding="{Binding Length}" /&gt;
                      &lt;/GridView&gt;
                  &lt;/ListView.View&gt;
              &lt;/ListView&gt;
  
          &lt;/Grid&gt;
  </code></pre>