WPF多行TextBlock CenterAlignment问题 [英] WPF Multiline TextBlock CenterAlignment Issue

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

问题描述

我在多行文本块中出现问题,该文本块居中对齐不正确

I'm having an issue with multiline text blocks where it is not center aligning properly

文字来了


abcde\nabc

这出来


  abcde
  abc

我想要的是


  abcde
   abc

这似乎很简单,我以为textblock会像这样自动居中对齐,但似乎没有.

This seems a simple thing and I would have thought that the textblock would center align like that automatically but it does not seem to.

推荐答案

尝试使用TextAlignment属性而不是HorizontalAlignment.第一个是TextBlock中文本的对齐方式,第二个是父容器中TextBlock的对齐方式.

Try the TextAlignment property instead of HorizontalAlignment. First one is the alignment of text in the TextBlock, second the alignment of the TextBlock in the parent container.

这篇关于WPF多行TextBlock CenterAlignment问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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