【发布时间】:2017-04-14 03:34:09
【问题描述】:
这是我的问题:
当我创建一个 StackPanel 并在其中添加两个或多个具有不同背景颜色的 TextBlock 时,有时会有一条奇怪的细线将它们分开。我想知道可能是什么原因以及如何解决它?
请看下面的代码示例。
<Grid x:Name="Grid" d:LayoutOverrides="LeftPosition, RightPosition" Margin="4">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<StackPanel x:Name="StackPanel1" Grid.Column="0" Margin="0,0,0.5,0">
<TextBlock x:Name="textBlock1" Background="#FF3C2C30" Foreground="{x:Null}" Height="60"/>
<TextBlock x:Name="textBlock2" Background="#FF303646" Foreground="{x:Null}" Height="60"/>
<TextBlock x:Name="textBlock3" Background="#FF3C2C30" Foreground="{x:Null}" Height="60"/>
<TextBlock x:Name="textBlock4" Background="#FF303646" Foreground="{x:Null}" Height="60"/>
<TextBlock x:Name="textBlock5" Background="#FF3C2C30" Foreground="{x:Null}" Height="60"/>
</StackPanel>
<StackPanel x:Name="StackPanel2" Grid.Column="1" Margin="0.5,0,0,0">
<TextBlock x:Name="textBlock6" Background="#FF303646" Foreground="{x:Null}" Height="42.9"/>
<TextBlock x:Name="textBlock7" Background="#FF3C2C30" Foreground="{x:Null}" Height="42.9"/>
<TextBlock x:Name="textBlock8" Background="#FF303646" Foreground="{x:Null}" Height="42.9"/>
<TextBlock x:Name="textBlock9" Background="#FF3C2C30" Foreground="{x:Null}" Height="42.9" />
<TextBlock x:Name="textBlock10" Background="#FF303646" Foreground="{x:Null}" Height="42.9"/>
<TextBlock x:Name="textBlock11" Background="#FF3C2C30" Foreground="{x:Null}" Height="42.9"/>
<TextBlock x:Name="textBlock12" Background="#FF303646" Foreground="{x:Null}" Height="42.9"/>
</StackPanel>
</Grid>
下图显示了输出。我希望右侧的 TextBlocks 像左侧的一样链接。
【问题讨论】: