title: How to force zero pixel Gap between Consecutive Cells in WPF DataGrid
body: <p>i am building an application in WPF for a custom need. First i opted for custom controls, but later on figured out that much of what i needed was already implemented in Datagrid Control. However there is one small glitch:</p>
  
  <p>The problem with Datagrid is that it <strong>enforces</strong> a minimum of <strong>2 pixel gap</strong> between two consecutive cells (1 on each side of the Grid Line). Please have a look at the following diagram for clarity:</p>
  
  <p>.
  Please note the 2 pixels gap enforced by the Datagrid between the two consecutive cells:
  <a href="http://img265.imageshack.us/img265/3545/figurem.png" rel="nofollow">http://img265.imageshack.us/img265/3545/figurem.png</a></p>
  
  <p>(Stack overflow wouldn't let me add image to my question citing a spam protection policy for new users)</p>
  
  <p>.</p>
  
  <p>This doesn't suit my requirement as i want the content to appear "continuous" (There must not be this gap of 2 pixels; i want the connecting lines to look "connected"). i've tried fidgeting with the GridLinesVisibility, but it didn't help. The DataGrid is hosting a custom control like this:</p>
  
  <pre><code>&lt;DataGrid.Columns&gt;
              &lt;DataGridTemplateColumn Width="25" Header=""&gt;
                  &lt;DataGridTemplateColumn.CellTemplate&gt;
                      &lt;DataTemplate&gt;
                          &lt;ContentControl Content="{Binding Path=MyCustomControl}" Margin="0"&gt;&lt;/ContentControl&gt;
                      &lt;/DataTemplate&gt;
                  &lt;/DataGridTemplateColumn.CellTemplate&gt;
              &lt;/DataGridTemplateColumn&gt;
  
  ....
  &lt;/DataGrid.Columns&gt;
  </code></pre>
  
  <p>i have so far tried:</p>
  
  <ol>
  <li>Switching off the GridLine (see result here: <a href="http://img263.imageshack.us/img263/8602/figure2j.png" rel="nofollow">http://img263.imageshack.us/img263/8602/figure2j.png</a>)</li>
  <li>Setting the margin of the content property to 0.</li>
  <li>Searched google and stackoverflow</li>
  <li>Consulted some books.</li>
  </ol>
  
  <p>but nothing seems to come up.</p>
  
  <p>Is there a solution to this/some hack or a workaround or would i have to create everything from scratch? i have decent experience with c#, but i am new to WPF.</p>
  
  <p>Please Help.</p>