具有多个 <Run> 的 TextBlock间距 [英] TextBlock with multiple <Run> spacing

查看:14
本文介绍了具有多个 <Run> 的 TextBlock间距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定 Windows Phone 7.1 项目中的格式化文本块:

Given a formatted text block in Windows Phone 7.1 project:

<StackPanel Orientation="Horizontal">
    <TextBlock Foreground="DarkGray" VerticalAlignment="Bottom" Margin="0,0,0,8">
            <Run Text="total length "/>
            <Run Text="{Binding TotalHours}" FontSize="48"/>
            <Run Text="h "/>
            <Run Text=":" FontSize="48"/>
            <Run Text="{Binding TotalMinutes}" FontSize="48"/>
            <Run Text="m "/>
    </TextBlock>
</StackPanel>

在 VS 设计器中正确预览:

It is being previewed correctly in VS designer:

它在 Blend 中已经不是我想要的样子了:

It is already looking not the way I want in Blend:

它看起来就像在模拟器和真实设备中的 Blend(干得好 Blend 团队)一样.

It looks just as in Blend (good job Blend team) in emulator and a real device.

是什么在大 8 和 45 之前和之后添加了这些空格?

What adds those spaces before and after big 8 and 45?

如何强制我的布局看起来正确(就像在 VS 设计器中一样)?

How can I force my layout to look correctly (like in VS designer)?

推荐答案

如果您将所有 Runs 写在同一行中,空白区域就会消失.基本上,这里的新行是 UI 上的一个空白区域.

if you write all your Runs in the same line, the empty space will go away. Basically a new line here is one empty space on the UI.

<TextBlock Foreground="DarkGray" VerticalAlignment="Bottom" Margin="0,0,0,8"><Run Text="total length "/><Run Text="{Binding TotalHours}" FontSize="48"/><Run Text="h "/><Run Text=":" FontSize="48"/><Run Text="{Binding TotalMinutes}" FontSize="48"/><Run Text="m "/></TextBlock>

这篇关于具有多个 &lt;Run&gt; 的 TextBlock间距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆