title: ListBox 1px border - Default Border - Bd Style
body: <p>I've got this user control which is producing a 1px border around the ListBox.</p>
  
  <p>I've found out it's the default Bd Border. I just can't seem to work out how to style it so the 1px gap no longer appears.</p>
  
  <pre><code>&lt;UserControl x:Class="Thumbnails"
           xmlns:local="clr-namespace:ContentPresenter"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
           xmlns:sys="clr-namespace:System;assembly=mscorlib"
           mc:Ignorable="d" 
           d:DesignHeight="350" d:DesignWidth="800"&gt;
  &lt;UserControl.Resources&gt;
      &lt;local:ThumbImageHeightConverter x:Key="HeightConv" /&gt;
      &lt;local:ThumbImageWidthConverter x:Key="WidthConv" /&gt;
      &lt;local:InnerGridHeightConverter x:Key="InnerGridHeightConv" /&gt;
      &lt;local:ReflectWidthConverter x:Key="ReflectWidthConv" /&gt;
      &lt;local:ReflectCenterYConv x:Key="ReflectCenterYConv" /&gt;
      &lt;local:BorderThicknessScale x:Key="BorderThicknessScale" /&gt;
      &lt;local:BorderCornerRadiusScale x:Key="BorderCornerRadiusScale" /&gt;
  
      &lt;Storyboard x:Key="FadeUpAndFlash"&gt;
          &lt;!--&lt;DoubleAnimation From="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Duration="0:0:10" FillBehavior="Stop" /&gt;--&gt;
          &lt;DoubleAnimation From="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Duration="0:0:1" FillBehavior="Stop" /&gt;
      &lt;/Storyboard&gt;
      &lt;Storyboard x:Key="ReflectFadeUpAndFlash"&gt;
          &lt;!--&lt;DoubleAnimation From="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Duration="0:0:10" FillBehavior="Stop" /&gt;--&gt;
          &lt;DoubleAnimation From="0" To="0.75" Storyboard.TargetProperty="(UIElement.Opacity)" Duration="0:0:1" FillBehavior="Stop" /&gt;
      &lt;/Storyboard&gt;
  
      &lt;Style TargetType="{x:Type ListBox}"&gt;
          &lt;!-- Set the ItemTemplate of the ListBox to a DataTemplate which explains how to display an object of type BitmapImage. --&gt;
          &lt;Style.Resources&gt;
              &lt;!-- Background of selected item when focussed --&gt;
              &lt;SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Black"/&gt;
              &lt;!-- Background of selected item when not focussed --&gt;
              &lt;SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}"  Color="Black" /&gt;
  
          &lt;/Style.Resources&gt;
  
          &lt;Setter Property="ItemTemplate"&gt;
              &lt;Setter.Value&gt;
                  &lt;DataTemplate&gt;
                      &lt;Grid x:Name="ThumbGrid" VerticalAlignment="Top" Height="{Binding ElementName=ThumbListBox, Path=ActualHeight}"  &gt;
                          &lt;Grid.RowDefinitions&gt;
                              &lt;RowDefinition x:Name="ThumbGridThumbImgRow" Height="80*" &gt;&lt;/RowDefinition&gt;
                              &lt;RowDefinition x:Name="GridReflectRow" Height="20*" &gt;&lt;/RowDefinition&gt;
                          &lt;/Grid.RowDefinitions&gt;
  
                          &lt;Border x:Name="HighlightBorder" Padding="2" Margin="2" HorizontalAlignment="Center" VerticalAlignment="Center"&gt;
                              &lt;Border.Style&gt;
                                  &lt;Style TargetType="{x:Type Border}"&gt;
                                      &lt;Setter Property="BorderBrush" Value="Black"/&gt;
                                      &lt;Style.Triggers&gt;
                                          &lt;DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBoxItem}},Path=IsSelected}" Value="True"&gt;
  
                                              &lt;DataTrigger.Setters&gt;
                                                  &lt;Setter Property="BorderBrush" Value="Yellow"/&gt;
                                              &lt;/DataTrigger.Setters&gt;
                                              &lt;DataTrigger.EnterActions&gt;
                                                  &lt;BeginStoryboard Storyboard="{StaticResource FadeUpAndFlash}" Name="AnimateImageBorder" /&gt;
                                              &lt;/DataTrigger.EnterActions&gt;
                                              &lt;DataTrigger.ExitActions&gt;
                                                  &lt;StopStoryboard BeginStoryboardName="AnimateImageBorder" /&gt;
                                              &lt;/DataTrigger.ExitActions&gt;
  
                                              &lt;!--&lt;Setter Property="BorderBrush" Value="Yellow"/&gt;--&gt;
                                          &lt;/DataTrigger&gt;
                                      &lt;/Style.Triggers&gt;
                                  &lt;/Style&gt;
                              &lt;/Border.Style&gt;
                              &lt;Border.Resources&gt;
                                  &lt;sys:Int32 x:Key="HighlightBorderOrigRadius"&gt;18&lt;/sys:Int32&gt;
                              &lt;/Border.Resources&gt;
                              &lt;Border.CornerRadius&gt;
                                  &lt;MultiBinding Converter="{StaticResource BorderCornerRadiusScale}"&gt;
                                      &lt;Binding ElementName="HighlightBorder" Path="ActualWidth" /&gt;
                                      &lt;Binding Source="{StaticResource HighlightBorderOrigRadius}" /&gt;
                                  &lt;/MultiBinding&gt;
                              &lt;/Border.CornerRadius&gt;
                              &lt;Border.BorderThickness&gt;
                                  &lt;MultiBinding Converter="{StaticResource BorderThicknessScale}"&gt;
                                      &lt;Binding ElementName="HighlightBorder" Path="ActualWidth" /&gt;
                                  &lt;/MultiBinding&gt;
                              &lt;/Border.BorderThickness&gt;
                              &lt;Grid x:Name="ThumbInnerGrid"&gt;
                                  &lt;Grid.Height&gt;
                                      &lt;MultiBinding Converter="{StaticResource InnerGridHeightConv}"&gt;
                                          &lt;Binding ElementName="ThumbGrid" Path="ActualHeight" /&gt;
                                          &lt;Binding ElementName="HighlightBorder" Path="CornerRadius" /&gt;
                                          &lt;Binding ElementName="mask" Path="CornerRadius" /&gt;
                                      &lt;/MultiBinding&gt;
                                  &lt;/Grid.Height&gt;
                                  &lt;Border x:Name="mask" Background="Black"&gt;
  
                                      &lt;Border.Resources&gt;
                                          &lt;sys:Int32 x:Key="MaskBorderOrigRadius"&gt;15&lt;/sys:Int32&gt;
                                      &lt;/Border.Resources&gt;
                                      &lt;Border.CornerRadius&gt;
                                          &lt;MultiBinding Converter="{StaticResource BorderCornerRadiusScale}"&gt;
                                              &lt;Binding ElementName="mask" Path="ActualWidth" /&gt;
                                              &lt;Binding Source="{StaticResource MaskBorderOrigRadius}" /&gt;
                                          &lt;/MultiBinding&gt;
                                      &lt;/Border.CornerRadius&gt;
                                  &lt;/Border&gt;
                                  &lt;StackPanel x:Name="ThumbInnerStack" VerticalAlignment="Top"&gt;
                                      &lt;StackPanel.OpacityMask&gt;
                                          &lt;VisualBrush Visual="{Binding ElementName=mask}"/&gt;
                                      &lt;/StackPanel.OpacityMask&gt;
  
                                      &lt;Image x:Name="ThumbImg" Stretch="UniformToFill" &gt;
                                          &lt;Image.Height&gt;
                                              &lt;MultiBinding Converter="{StaticResource HeightConv}"&gt;
                                                  &lt;Binding ElementName="HighlightBorder" Path="ActualHeight" /&gt;
                                                  &lt;Binding ElementName="HighlightBorder" Path="BorderThickness" /&gt;
                                                  &lt;Binding ElementName="HighlightBorder" Path="Padding" /&gt;
                                              &lt;/MultiBinding&gt;
                                          &lt;/Image.Height&gt;
                                          &lt;Image.Width&gt;
                                              &lt;MultiBinding Converter="{StaticResource WidthConv}"&gt;
                                                  &lt;Binding ElementName="ThumbImg" Path="ActualHeight" /&gt;
                                                  &lt;Binding ElementName="HighlightBorder" Path="BorderThickness" /&gt;
                                                  &lt;Binding ElementName="HighlightBorder" Path="Padding" /&gt;
                                              &lt;/MultiBinding&gt;
                                          &lt;/Image.Width&gt;
                                          &lt;Image.Source&gt;
                                              &lt;BitmapImage UriSource="{Binding Path=Src}"&gt;&lt;/BitmapImage&gt;
                                          &lt;/Image.Source&gt;
                                      &lt;/Image&gt;
                                  &lt;/StackPanel&gt;
                              &lt;/Grid&gt; 
                          &lt;/Border&gt;
                          &lt;Border x:Name="ReflectBorder" Margin="0,-1,0,0" VerticalAlignment="Top" Height="{Binding ElementName=ThumbImg, Path=ActualHeight}" Grid.Row="1" Opacity="0.75" &gt;
                              &lt;Border.Style&gt;
                                  &lt;Style TargetType="{x:Type Border}"&gt;
  
                                      &lt;Style.Triggers&gt;
                                          &lt;DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBoxItem}},Path=IsSelected}" Value="True"&gt;
  
                                              &lt;DataTrigger.EnterActions&gt;
                                                  &lt;BeginStoryboard Storyboard="{StaticResource ReflectFadeUpAndFlash}" Name="AnimateImageReflection" /&gt;
                                              &lt;/DataTrigger.EnterActions&gt;
                                              &lt;DataTrigger.ExitActions&gt;
                                                  &lt;StopStoryboard BeginStoryboardName="AnimateImageReflection" /&gt;
                                              &lt;/DataTrigger.ExitActions&gt;
  
                                              &lt;!--&lt;Setter Property="BorderBrush" Value="Yellow"/&gt;--&gt;
                                          &lt;/DataTrigger&gt;
                                      &lt;/Style.Triggers&gt;
                                  &lt;/Style&gt;
                              &lt;/Border.Style&gt;
                              &lt;Border.Resources&gt;
                                      &lt;sys:Int32 x:Key="MaskBorderOrigRadius"&gt;15&lt;/sys:Int32&gt;
                                  &lt;/Border.Resources&gt;
                                  &lt;Border.CornerRadius&gt;
                                      &lt;MultiBinding Converter="{StaticResource BorderCornerRadiusScale}"&gt;
                                      &lt;Binding ElementName="ReflectBorder" Path="ActualWidth" /&gt;
                                          &lt;Binding Source="{StaticResource MaskBorderOrigRadius}" /&gt;
                                      &lt;/MultiBinding&gt;
                                  &lt;/Border.CornerRadius&gt;
  
                              &lt;Border.Width&gt;
                                  &lt;MultiBinding Converter="{StaticResource ReflectWidthConv}"&gt;
                                      &lt;Binding ElementName="HighlightBorder" Path="ActualWidth" /&gt;
                                      &lt;Binding ElementName="HighlightBorder" Path="BorderThickness" /&gt;
                                  &lt;/MultiBinding&gt;
                              &lt;/Border.Width&gt;
                              &lt;Border.Background&gt;
                                  &lt;VisualBrush Visual="{Binding ElementName=ThumbImg}"&gt;
                                      &lt;VisualBrush.Transform&gt;
                                          &lt;ScaleTransform ScaleX="1" ScaleY="-1" CenterX="200"&gt;
                                              &lt;ScaleTransform.CenterY&gt;
                                                  &lt;MultiBinding Converter="{StaticResource ReflectCenterYConv}"&gt;
                                                      &lt;Binding ElementName="ThumbImg" Path="ActualHeight" /&gt;
                                                  &lt;/MultiBinding&gt;
                                              &lt;/ScaleTransform.CenterY&gt;
                                          &lt;/ScaleTransform&gt;
                                      &lt;/VisualBrush.Transform&gt;
                                  &lt;/VisualBrush&gt;
                              &lt;/Border.Background&gt;
                              &lt;Border.OpacityMask&gt;
                                  &lt;LinearGradientBrush StartPoint="0,0" EndPoint="0,1.3"&gt;
                                      &lt;GradientStop Offset="0" Color="Black"&gt;&lt;/GradientStop&gt;
                                      &lt;GradientStop Offset="0.15" Color="Transparent"&gt;&lt;/GradientStop&gt;
                                  &lt;/LinearGradientBrush&gt;
                              &lt;/Border.OpacityMask&gt;
                          &lt;/Border&gt;
                          &lt;Grid Grid.Row="1" MaxWidth="{Binding ElementName=ThumbImg, Path=ActualWidth}"&gt;
                              &lt;Border Padding="10,0,10,25"&gt;
                                  &lt;Viewbox VerticalAlignment="Top" MaxWidth="{Binding ElementName=ThumbImg, Path=ActualWidth}"&gt;
                                      &lt;Label x:Name="ThumbTitle" Margin="0,-5,0,0" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Top" Content="{Binding Path=Title}" FontFamily="Arial" Foreground="White" /&gt;
                                  &lt;/Viewbox&gt;
                              &lt;/Border&gt;
                          &lt;/Grid&gt;
                      &lt;/Grid&gt;
                  &lt;/DataTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
          &lt;Setter Property="ItemsPanel"&gt;
              &lt;Setter.Value&gt;
                  &lt;ItemsPanelTemplate&gt;
                      &lt;VirtualizingStackPanel x:Name="ThumbListStack" Orientation="Horizontal" Loaded="StackPanel_Loaded"&gt;
                          &lt;VirtualizingStackPanel.RenderTransform&gt;
                          &lt;TranslateTransform X="0" Y="0" /&gt;
                          &lt;/VirtualizingStackPanel.RenderTransform&gt;
                      &lt;/VirtualizingStackPanel&gt; 
                  &lt;/ItemsPanelTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
          &lt;Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" /&gt;
          &lt;Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled" /&gt;
          &lt;Setter Property="Background" Value="Black"/&gt;
  
      &lt;/Style&gt;
  
  &lt;/UserControl.Resources&gt;
  
      &lt;UserControl.DataContext&gt;
          &lt;ObjectDataProvider ObjectType="{x:Type local:ThumbImageLoader}" MethodName="LoadImagesv2" IsAsynchronous="True"  /&gt;
  &lt;/UserControl.DataContext&gt;
  
  
  &lt;!-- This ListBox is the Content of the Window. Normally you would have a panel of some type as the Window's Content, but let's keep it simple. --&gt;
  &lt;Grid x:Name="ThumbListBoxGrid"&gt;
      &lt;ListBox x:Name="ThumbListBox" ItemsSource="{Binding}" VerticalAlignment="Top" Height="{Binding ElementName=ThumbListBoxGrid, Path=ActualHeight}" IsSynchronizedWithCurrentItem="True" /&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>How do I style the default Border?</p>