Silverlight 3 TextBlock 在文本上方留下空白
我的 XAML 中有以下内容:
<Grid x:Name="LayoutRoot" Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
<RowDefinition Height="7"/>
<RowDefinition Height="57"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" FontSize="18">Title Text</TextBlock>
<Rectangle Grid.Row="1" Margin="0,2" Height="3" HorizontalAlignment="Stretch" Fill="#ff000000"/>
<Border Grid.Row="2" Margin="0" Padding="0" BorderBrush="Black" BorderThickness="1">
<TextBlock Margin="0" Padding="0" FontSize="55">123</TextBlock>
</Border>
</Grid>
问题是底部 TextBlock 中的文本上方有一个空格(大约 10px)。我似乎只能通过使用更小的字体来摆脱这个空间。
有谁知道为什么会出现这个空间,以及我能做些什么?
谢谢。
I have the following in my XAML:
<Grid x:Name="LayoutRoot" Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
<RowDefinition Height="7"/>
<RowDefinition Height="57"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" FontSize="18">Title Text</TextBlock>
<Rectangle Grid.Row="1" Margin="0,2" Height="3" HorizontalAlignment="Stretch" Fill="#ff000000"/>
<Border Grid.Row="2" Margin="0" Padding="0" BorderBrush="Black" BorderThickness="1">
<TextBlock Margin="0" Padding="0" FontSize="55">123</TextBlock>
</Border>
</Grid>
The problem is that there is a space (about 10px) above the text in the bottom TextBlock. I can only seem to get rid of this space by using a much smaller font size.
Does anyone have an idea of why this space is showing up, and what I can do about it?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信这是因为 TextBlock 上的默认 VerticalAlignment 是 Stretch。尝试将其设置为居中:
如果您确实需要将其向上推,您可以添加负的上边距。
I believe it is because the default VerticalAlignment on a TextBlock is Stretch. Try setting it to Center:
If you really need to nudge it up you could add a negative top margin.