我只是用一些包含 ! (感叹号)在最后。和 !出现在文本前面。
所以代替
some text!
我明白了
!some text
这怎么可能?
有什么线索吗?
谢谢!
代码
TextBlock tb = new TextBlock();
tb.Text = Text;
lstItems.Children.Add(tb); // lstItems is a StackPanel
最佳答案
TextBlock
的祖先很可能将其 FlowDirection
设置为 RightToLeft
。尝试将其重置为 LeftToRight
:
tb.FlowDirection = FlowDirection.LeftToRight;
编辑:原因解释起来有点复杂;这与如何bi-directional text有关被渲染。来自维基百科:
Punctuation characters […] can appear in both LTR and RTL scripts. They are called "weak" characters because they do not contain any directional information. So it is up to the software to decide in which direction these "weak" characters will be placed.
WPF 将您的 !
与文本的其余部分分开,并将其放置在您的方向流中(在本例中,向 right left ).
关于c# - 为什么感叹号出现在文字前面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10805735/