WPF:如何证明段落中的所有行(带换行符的行)

时间:2010-04-27 20:04:45

标签: wpf xaml flowdocument

我在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字中可实现的相同输出,例如,如果我们在一行上有3个单词,我们左边会有1个单词,一个在中心,一个在右边)

谢谢, 萨姆

2 个答案:

答案 0 :(得分:1)

我认为你不能达到你想要的效果。即使用一个关闭段落替换<LineBreak/>(我知道你不想要):

<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.
</Paragraph>
<Paragraph TextAlignment="Justify">
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>

段落的最后一行是左对齐的。

答案 1 :(得分:0)

这可能是你想要的东西:

<table style="margin-top: 100px;">
  <tr>
    <td>
      <div style="margin-top: 50px;background-color:blue; height:100px;">

        <div id="id" style="background-color: red; width: 20px; height:20px;">
        </div>
      </div>
    </td>
  </tr>
</table>

希望有帮助...