加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

xaml – 为什么TextBlock从文本中修剪结尾的空格?

发布时间:2020-12-13 20:10:15 所属栏目:Windows 来源:网络整理
导读:这是我的TextBlocks StackPanel Orientation="Horizontal" Margin="0,3,0" TextBlock Text="6 or more characters,at least one letter and a number," FontFamily="Segoe UI" Foreground="#000000" FontSize="13"/ TextBlock Text="no symbols" FontFamily=
这是我的TextBlocks
<StackPanel Orientation="Horizontal" Margin="0,3,0">
    <TextBlock Text="6 or more characters,at least one letter and a number,"  FontFamily="Segoe UI" Foreground="#000000" FontSize="13"/>
    <TextBlock Text="no symbols"  FontFamily="Segoe UI" Foreground="#000000" FontSize="13"/>
</StackPanel>

这里是输出(屏幕截图)

为什么TextBlock修剪结尾的空格?但是当我提供领先的空间时它工作正常.

它看起来像xml:space =“保留”应该做的伎俩(见 Preserving Whitespace in XAML),但这似乎没有在Windows Store应用程序(它在WPF中).

如果您使用不间断空格字符它工作正常

<TextBlock Text="6 or more characters,&#160;&#160;&#160;&#160;&#160;&#160;&#160;"  ....

我想你可以尝试在Text属性上构建一个转换器来检查尾随空格并替换为非空格 – 假定发生的截断不会太早发生.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读