2012-02-16 81 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