2012-02-16 75 views
0

请帮忙弄清楚这个奇怪的白色轮廓TextBlock是怎么出现的。TextBlock有奇怪的白色轮廓

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); 

回答

2

,我不认为它属于TextBlock,除非你有一个风格的地方它增加了它,它似乎更可能属于包含它的。

+2

确实。如果您没有使用ListBox的选择功能,您可能需要查看ItemsControl/ScrollViewer + StackPanel组合。 – Robaticus 2012-02-16 19:37:56

+0

@Robaticus谢谢你!这真的是很好的建议!我只是用ItemsControl替换了ListBox,一切都很好!凉! – 2012-02-16 19:48:56