我想减少
TextBlock
中制表符的宽度。制表符相当于大约 8 个字符。我想减少到大约 4 个空格。
TextBlock textBlock = new TextBlock
{
Text = "Some text\r\n\tLine with tab.\r\n\tAnother line",
};
我所看到的:
Some text
Line with tab.
Another line
我想要什么:
Some text
Line with tab.
Another line
如何将每次出现的
\t
替换为四个(或您选择的数字)spaces
?
这种方法可以通过修改代码来实现
textBlock.Text = textBlock.Text.Replace("\t", " ");