TextBlock 有奇怪的白色轮廓

发布于 2025-01-06 12:53:47 字数 1043 浏览 3 评论 0原文

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

在此处输入图像描述

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

秋日私语 2025-01-13 12:53:47

我不认为它属于 TextBlock 除非你有一个添加它的样式,它似乎更可能属于包含它的 ListBox

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文