Search code examples
wpfxamltextblock

TextBlock has strange white outline


Please help to figure out how this strange white outline of TextBlock appears.

enter image description here

XAML

<StackPanel Grid.ColumnSpan="2" Grid.Row="1" Grid.RowSpan="2"  >
   <local:Marquee x:Name="marquee1"   Height="100" Width="800" Margin="0,0,0,0">
                <ListBox Name="lstItems"  ItemsPanel="{StaticResource ItemsPanelTemplate1}"   VerticalAlignment="Center" Background="{x:Null}" >                  
                 </ListBox>
   </local:Marquee>            
</StackPanel>

C#

TextBlock tb = new TextBlock();

tb.IsEnabled = false;
tb.Text = Text;
tb.FontWeight = FontWeights.Normal;
tb.Foreground = color;
tb.FontSize = marquee1.Height / koeff;
tb.TextWrapping = TextWrapping.Wrap;
if (!string.IsNullOrEmpty(fFamily))
tb.FontFamily = new FontFamily(fFamily);
if (bColor != null)
{
if (bColor != Brushes.Transparent)
tb.Background = bColor;
}
lstItems.Items.Add(tb);

Solution

  • I don't think it belongs to the TextBlock unless you have a style somewhere which adds it, it seems more likely that it belongs to the ListBox containing it.