WPF:如何对齐段落中的所有行(也有换行符的行)
我在 FlowDocument 中有一些段落,我需要的是证明所有行(甚至是带有换行符的行)的合理性,
这是一个代码示例:
<Paragraph TextAlignment="Justify">
"One of the most important operations necessary when text materials
are prepared for printing or display is the task of dividing long
paragraphs into individual lines.<LineBreak/>
When this job has been done well,
people will not be aware of the fact that the words they are reading
have been broken apart arbitrarily and placed into a somewhat rigid
and unnatural rectangular framework; but if the job has been done
poorly, readers will be distracted by bad breaks that interrupt
their train of thought."
</Paragraph>
上面的输出不会证明有换行符的行合理,该行将是左对齐,我需要的是所有行的宽度相同,
这如何实现?
(请注意,如果段落有换行符并且设置为对齐,则所需的输出与 ms word 中可实现的输出相同,例如,如果一行上有 3 个单词,则左侧有 1 个单词,中间有 1 个单词右边有一个)
谢谢, 山姆
i have a some paragraphs within a FlowDocument, and what i need is to justify all lines (even lines with line breaks)
Here's a code sample:
<Paragraph TextAlignment="Justify">
"One of the most important operations necessary when text materials
are prepared for printing or display is the task of dividing long
paragraphs into individual lines.<LineBreak/>
When this job has been done well,
people will not be aware of the fact that the words they are reading
have been broken apart arbitrarily and placed into a somewhat rigid
and unnatural rectangular framework; but if the job has been done
poorly, readers will be distracted by bad breaks that interrupt
their train of thought."
</Paragraph>
The output of the above will not justify the line that has a line break, this line will be aligned left, what i need is a same-width lines for all lines
How could this be achieved?
(Note that the desired output is the same output achievable in ms word if a paragraph has line breaks and is set to justify, for example if we have 3 words on a line we'll have 1 word on the left, one in the center and one on the right)
Thanks,
Sam
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不认为你能达到你想要的目标。即使您将
替换为一个关闭的段落(我知道您不想要):该段落的最后一行是左对齐的。
I don't think you can achieve what you want. Even if you replace the
<LineBreak/>
with a close paragraph (which I know you don't want):the last line of the paragraph is left justified.
这是否是您想要做的事情:
希望有帮助...
Is this what you might be wanting todo:
Hope that helps...