WebEnh

.net7 mvc jquery bootstrap json 学习中 第一次学PHP,正在研究中。自学进行时... ... 我的博客 https://enhweb.github.io/ 不错的皮肤:darkgreentrip,iMetro_HD
  首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

WPF中TextBlock文本换行与行间距

Posted on 2023-07-10 17:39  WebEnh  阅读(1470)  评论(0)    收藏  举报

换行符:

C#代码中:\r\n 或  \r 或 \n     

XAML中:
 或 

注:\r 回车 (carriage return 缩写),\n 新行 (new line 缩写)。

 

行间距:

LineHeight属性

 

示例:

<TextBlock LineHeight="20" Text=" I'm line1 &#x0A; I'm line 2"/>

<TextBlock LineHeight="20" Text=" I'm line1 &#x0D; I'm line 2"/>

 

\r与\n的区别:

\r :到当前行的最左边。

\n:向下移动一行,并不移动左右。

Linux中:\n表示回车+换行;

Windows中:\r\n表示回车+换行。

Mac中:\r表示回车+换行。