This problem has been troubled for a long time, into the continuous efforts, finally solved
<richtextbox margin= "0,44,10,0" name= "Codetext" verticalscrollbarvisibility= "Auto" Horizontalscrollbarvisibility= "Auto" horizontalalignment= "right" verticalalignment= "Top" width= "494" Height= "435" >
<RichTextBox.Resources>
<style targettype= "{x:type Paragraph}" >
<setter property= "Margin" value= "0"/>
</Style>
</RichTextBox.Resources>
<RichTextBox.Document>
<flowdocument pagewidth= "2048" >
</FlowDocument>
</RichTextBox.Document>
</RichTextBox>
The red is the solution, here my idea is to set the width of 2048, so that when the length of 2048 will be changed line, you can certainly set the larger, but there is a flaw is the scroll bar has been there. Please leave a message if you solve the scroll bar problem.
Close-up note: The 2048 here is actually a bits number, which means that when you write 256 characters (256*8=2048) in a row, the line will be wrapped