2010-04-27 22 views
2

我有一個的FlowDocument內的一些段落,和我需要的是證明所有行(即使有斷行線)WPF:如何證明中段落的所有行(以換行符太)

這裏有一個代碼示例:

<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> 

上面會沒有理由,有一個換行符的線,這條線將左對齊的輸出,我需要的是所有的線寬度相同線路

如何這可以實現嗎? (注意,如果一個段落有換行符並且設置爲對齊,例如,如果我們在一行上有3個單詞,我們將在左邊有1個單詞,那麼期望的輸出是以ms爲單位可實現的相同輸出,在中心之一,一個在右邊)

感謝, 山姆

回答

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> 

段落的最後一行左對齊。

+0

如果上面是無法實現的,作爲一種替代我想手動證明文本知道每一行的換行符,可以以某種方式實現嗎?比如爲每一行設置一個寬度和手動間距,以便我得到一個合理的段落? – sam 2010-04-30 07:55:44

0

這是你可能會想什麼TODO:

<Paragraph Margin="5,5,5,5"> <!--You can assign margin here or below to give you the spacing needed--> 
<!--You can set width as need, but new line can be done in a textblocks LineBreak--> 
<TextBlock TextAlignment ="Justify" TextWrapping="Wrap" Width="150"> 
    One of the most <LineBreak/>important operations necessary when text materials 
    are prepared for printing or display is the task of dividing long 
    paragraphs into individual lines. 
</TextBlock>        

希望幫助...

+0

7年後,我得到了答案:)對不起,我將無法驗證你的答案,因爲這個項目很久以前就被拋棄了,希望別人能夠驗證它並從中受益 – sam 2017-01-10 22:13:17

相關問題