2

有没有办法在TextBlock元素中实现自定义文本换行算法?我的意思是根据控件大小自动包装。目前我使用TextWrapping属性,但它没有按我预期的那样工作。例如我有这个字符串:

pleasant /'plez(ə)nt/

目前,此文本可以包装为:

pleasant /'plez
(ə)nt/

但我需要这样的东西(只在空白处换行):

pleasant
/'plez(ə)nt/

据我了解,当前的实现也包含标点符号,但这会导致复杂文本(如单词转录)出现意外行为。

4

1 回答 1

0

你试过了吗

string s = "pleasant /'plez(ə)nt/";
string[] words = s.Split(' ');
foreach (string word in words)
{
    Console.WriteLine(word);
}

输出应该是:
令人愉快
的 /'plez(ə)nt/

于 2012-11-06T09:14:35.660 回答