title: Extra Whitespace with ListBox and UniformGrid
body: <p>I'm making a calendar as an exercise, and I get the Listbox Items to generate correctly. However, I don't want any spaces in between the borders. I have set HorizontalContentAlignment to stretch, and that didn't fix it.</p>
  <pre class="lang-xml prettyprint-override"><code>        &lt;Grid&gt;
              &lt;ListBox x:Name=&quot;monthCalendarListbox&quot;
                       Grid.RowSpan=&quot;2&quot;
                       BorderThickness=&quot;0&quot;
                       HorizontalContentAlignment=&quot;Stretch&quot;
                       VerticalContentAlignment=&quot;Stretch&quot;&gt;
                  &lt;ListBox.ItemsPanel&gt;
                      &lt;ItemsPanelTemplate&gt;
                          &lt;UniformGrid Rows=&quot;5&quot;
                                       Columns=&quot;7&quot;/&gt;
                      &lt;/ItemsPanelTemplate&gt;
                  &lt;/ListBox.ItemsPanel&gt;
                  &lt;ListBox.ItemTemplate&gt;
                      &lt;DataTemplate&gt;
                          &lt;Border BorderBrush=&quot;Black&quot;
                                  BorderThickness=&quot;1&quot;&gt;
                              &lt;StackPanel Background=&quot;Transparent&quot;
                                          HorizontalAlignment=&quot;Stretch&quot;&gt;
                                  &lt;Label Content=&quot;{Binding DayNumber}&quot;/&gt;
                                  &lt;Label Content=&quot;{Binding Message}&quot;
                                         VerticalAlignment=&quot;Center&quot;
                                         HorizontalAlignment=&quot;Center&quot;/&gt;
                              &lt;/StackPanel&gt;
                          &lt;/Border&gt;
                      &lt;/DataTemplate&gt;
                  &lt;/ListBox.ItemTemplate&gt;
              &lt;/ListBox&gt;
          &lt;/Grid&gt;
  </code></pre>
  <p><a href="https://i.stack.imgur.com/q4QWA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/q4QWA.png" alt="Extra Whitespace" /></a></p>
  <p><strong>EDIT:</strong></p>
  <p>It looks like ListBoxItem was getting a transparent border thrown in in addition to some padding (mentioned in the comments). So no more spacing but now I have double thick borders where the ListBoxItems meet. Any idea how to fix that?</p>
  <pre class="lang-xml prettyprint-override"><code>        &lt;Grid&gt;
              &lt;ListBox x:Name=&quot;monthCalendarListbox&quot;
                       BorderThickness=&quot;0&quot;
                       HorizontalContentAlignment=&quot;Stretch&quot;
                       VerticalContentAlignment=&quot;Stretch&quot;&gt;
                  &lt;ListBox.ItemContainerStyle&gt;
                      &lt;Style TargetType=&quot;ListBoxItem&quot;&gt;
                          &lt;Style.Resources&gt;
                              &lt;SolidColorBrush x:Key=&quot;x:Static SystemColors.HighlightBrushKey&quot; Color=&quot;Transparent&quot;/&gt;
                              &lt;SolidColorBrush x:Key=&quot;x:Static SystemColors.ControlBrushKey&quot; Color=&quot;Transparent&quot;/&gt;
                              &lt;SolidColorBrush x:Key=&quot;x:Static SystemColors.HighlightTextBrushKey&quot; Color=&quot;Black&quot;/&gt;
                          &lt;/Style.Resources&gt;
                          &lt;Setter Property=&quot;BorderBrush&quot; Value=&quot;Black&quot;/&gt;
                          &lt;Setter Property=&quot;BorderThickness&quot; Value=&quot;1&quot;/&gt;
                      &lt;/Style&gt;
                  &lt;/ListBox.ItemContainerStyle&gt;
                  &lt;ListBox.ItemsPanel&gt;
                      &lt;ItemsPanelTemplate&gt;
                          &lt;UniformGrid Rows=&quot;5&quot;
                                       Columns=&quot;7&quot;/&gt;
                      &lt;/ItemsPanelTemplate&gt;
                  &lt;/ListBox.ItemsPanel&gt;
                  &lt;ListBox.ItemTemplate&gt;
                      &lt;DataTemplate&gt;
                          &lt;StackPanel Background=&quot;Transparent&quot;&gt;
                              &lt;Label Content=&quot;{Binding DayNumber}&quot;/&gt;
                              &lt;Label Content=&quot;{Binding Message}&quot;
                                     VerticalAlignment=&quot;Center&quot;
                                     HorizontalAlignment=&quot;Center&quot;/&gt;
                          &lt;/StackPanel&gt;
                      &lt;/DataTemplate&gt;
                  &lt;/ListBox.ItemTemplate&gt;
              &lt;/ListBox&gt;
          &lt;/Grid&gt;
  </code></pre>
  <p><a href="https://i.stack.imgur.com/A7lDY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/A7lDY.png" alt="Border Thickness Issue" /></a></p>