title: Listbox Separator in WPF and Omission of Final Separator
body: <p>I have two things I'm trying to achieve:</p>
  
  <ol>
  <li>Add a horizontal separator between listbox items in WPF.</li>
  <li>Don't show the separator at the bottom of the final listbox item.</li>
  </ol>
  
  <p>My current layout is pictured here:</p>
  
  <p><img src="https://i.stack.imgur.com/jmgeb.png" alt="enter image description here"></p>
  
  <p>This shows 2 listbox items (though I have no way of knowing how many items could potentially be generated). I would like them separated by a horizontal separator, except on the last listbox item so there isn't a spare separator at the bottom of the pane. How can I achieve this in XAML? See my current XAML here:</p>
  
  <pre><code> &lt;TabItem Header="Third Party Updates"&gt;
              &lt;Grid&gt;
                  &lt;TextBlock Name="ThirdPartyNoManifestTextBox" Width="Auto" HorizontalAlignment="Left" Margin="267,22,0,0" TextWrapping="Wrap" Text="{Binding Path=WindowsUpdateCompliance, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top" FontSize="14" Foreground="DarkSlateBlue"/&gt;
                  &lt;Button Name="CheckforThirdPartyUpdatesButton" Content="Check for Third Party Updates" Margin="10,11,339,304" Click="CheckforThirdPartyUpdatesButton_Click" MaxWidth="200" Grid.Column="1" Grid.Row="1"/&gt;
                  &lt;ListBox Name="ThirdPartyListBox" ItemsSource="{Binding}" Margin="0,70,0,0"&gt;
                      &lt;ListBox.ItemTemplate&gt;
                          &lt;DataTemplate&gt;
                              &lt;StackPanel Orientation="Horizontal"&gt;
                                  &lt;Button Name="ThirdPartyInstallButton" Content="Install" Click="InstallThirdPartyUpdatesButton_Click" Margin="5,5,0,0" Height="25"&gt;&lt;/Button&gt;
                                  &lt;Button Name="ThirdPartyPostoneButton" Content="Postpone" Click ="PostponeThirdPartyUpdatesButton_Click" Margin="5,5,0,0" Height="25"&gt;&lt;/Button&gt;
                                  &lt;Grid&gt;
                                      &lt;Grid.ColumnDefinitions&gt;
                                          &lt;ColumnDefinition /&gt;
                                          &lt;ColumnDefinition /&gt;
                                      &lt;/Grid.ColumnDefinitions&gt;
                                      &lt;Grid.RowDefinitions&gt;
                                          &lt;RowDefinition /&gt;
                                          &lt;RowDefinition /&gt;
                                          &lt;RowDefinition /&gt;
                                          &lt;RowDefinition /&gt;
                                          &lt;RowDefinition /&gt;
                                      &lt;/Grid.RowDefinitions&gt;
                                      &lt;Label Content="•" Grid.Row="1" VerticalContentAlignment="Center"/&gt;
                                      &lt;Label Content="•" Grid.Row="2" VerticalContentAlignment="Center"/&gt;
                                      &lt;Label Content="•" Grid.Row="3" VerticalContentAlignment="Center"/&gt;
                                      &lt;Label Content="•" Grid.Row="4" VerticalContentAlignment="Center"/&gt;
                                      &lt;StackPanel Orientation="Horizontal" Grid.Column="1"&gt;
                                          &lt;Label Name="MissingRequiredAppGenericTextBlock" VerticalAlignment="Center" Content="Required application update detected:" FontWeight="SemiBold" FontSize="12"/&gt;
                                          &lt;Label Name="RequiredAppNameTextBlock" VerticalAlignment="Center" Content="{Binding Item2.Name}" Foreground="MidnightBlue" FontSize="13"/&gt;
                                          &lt;Label Grid.Column="1" Grid.Row="1" Name="RequiredAppVersionTextBlock" Content="{Binding Item2.RequiredVersion}" VerticalAlignment="Center" Foreground="MidnightBlue" FontSize="13"/&gt;
                                      &lt;/StackPanel&gt;
                                      &lt;TextBlock Grid.Column="1" Grid.Row="1" Name="RequiredAppCustomUIMessageTextBlock" Text="{Binding Item2.CustomUIMessage}" TextWrapping="Wrap" VerticalAlignment="Center"/&gt;
                                      &lt;TextBlock Grid.Column="1" Grid.Row="2" VerticalAlignment="Center"&gt;
                                      &lt;Hyperlink Name="Link" NavigateUri="{Binding Item2.TT}" RequestNavigate="Hyperlink_RequestNavigate"&gt;
                                          &lt;TextBlock Text="{Binding Item2.TT}"/&gt;
                                      &lt;/Hyperlink&gt;
                                  &lt;/TextBlock&gt;
                                      &lt;StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="3"&gt;
                                          &lt;TextBlock Text="The following processes will be closed prior to install: " VerticalAlignment="Center" /&gt;
                                          &lt;TextBlock Text="{Binding Item2.ListOfProcessesToClose}" FontWeight="SemiBold" Foreground="Red" VerticalAlignment="Center"/&gt;
                                      &lt;/StackPanel&gt;
                                      &lt;StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="4"&gt;
                                          &lt;TextBlock Text="You have used " VerticalAlignment="Center" /&gt;
                                          &lt;TextBlock Text="{Binding Item3.UsedDeferrals}" VerticalAlignment="Center"/&gt;
                                          &lt;TextBlock Text=" of " VerticalAlignment="Center"/&gt;
                                          &lt;TextBlock Text="{Binding Item2.MaxDefferals}" VerticalAlignment="Center"/&gt;
                                          &lt;TextBlock Text=" deferrals for this update." VerticalAlignment="Center"/&gt;
                                      &lt;/StackPanel&gt;
                                  &lt;/Grid&gt;
                              &lt;/StackPanel&gt;
                          &lt;/DataTemplate&gt;
                      &lt;/ListBox.ItemTemplate&gt;
                      &lt;ListBox.ItemContainerStyle&gt;
                          &lt;Style TargetType="{x:Type ListBoxItem}"&gt;
                              &lt;Style.Triggers&gt;
  
                                  &lt;DataTrigger Binding="{Binding PostponeClicked}" Value="1"&gt;
                                      &lt;Setter Property="Visibility" Value="Hidden"&gt;&lt;/Setter&gt;
                                  &lt;/DataTrigger&gt;
  
                                  &lt;Trigger Property="Control.IsMouseOver" Value="True"&gt;
                                      &lt;Setter Property="Control.BorderBrush" Value="SteelBlue" /&gt;
                                      &lt;Setter Property="Control.BorderThickness" Value="1" /&gt;
                                  &lt;/Trigger&gt;
                              &lt;/Style.Triggers&gt;
                          &lt;/Style&gt;
                      &lt;/ListBox.ItemContainerStyle&gt;
                  &lt;/ListBox&gt;
              &lt;/Grid&gt;
          &lt;/TabItem&gt;
  </code></pre>
  
  <p><strong><em>Update</em></strong></p>
  
  <p>Added suggested separator code. Separator is now present but does not fill the available horizontal space:</p>
  
  <p><img src="https://i.stack.imgur.com/bY0V4.png" alt="enter image description here"></p>