gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 15:18:27 24 4
gpt4 key购买 nike

这是我的 TextBlock s:

<StackPanel Orientation="Horizontal" Margin="0,3,0,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>
这是输出(屏幕截图):
enter image description here
为什么 TextBlock修剪结尾空格?但是,当有前导空格时它工作正常。

最佳答案

它看起来像 xml:space="preserve"应该可以解决问题(请参阅 Preserving Whitespace in XAML ),但这似乎不适用于 Windows Store 应用程序(它适用于 WPF)。

如果您使用不间断空格字符 &#160;它确实有效

 <TextBlock Text="6 or more characters, at least one letter and a number,&#160;&#160;&#160;&#160;&#160;&#160;&#160;"  ....

我想您可以尝试在 Text 上构建转换器检查尾随空格并替换为不间断空格的属性 - 假设正在发生的截断不会发生得太早。

关于xaml - 为什么 TextBlock 会修剪文本中的结尾空格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14337623/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com