I am programmatically creating a FlowDocument, then translating it to Rich Text, so a user can edit it in a Rich Text box. I cannot figure out how to insert a horizontal line in the FlowDocument that will display across the whole width of the edit box (and subsequent rendered PDF).
I found this thread which (allegedly) shows how to do exactly what I want, in XAML:
Simple (I think) Horizontal Line in WPF?
And this one:
http://social.msdn.microsoft.com/forums/en-US/wpf/thread/bcd334c7-8e2b-4e59-a344-4376b30cf847/
I have attempted to replicate this programmatically, like this:
Line pLine = new Line();
pLine.Stretch = Stretch.Fill;
pLine.Stroke = Brushes.Black;
pLine.X2 = 1;
para.Inlines.Add( pLine );
But, this ends up displaying nothing at all in the resulting RTF edit box. The rest of the Rich Text is there. Just no line at all.
I also tried creating a Table and inserting the text I want to come after the horizontal line into a cell. Then I set a custom border, just for the top of the Table. That gives me a horizontal line, but it doesn't go all the way across the screen (after it's converted to RTF and shown in the RTF edit box), and it doesn't show at all after I render it into a PDF.
I have resorted to the complete hack of just inserting a Run of 60 underscore ('_') characters and a LineBreak. That "works", but it sucks. Can anybody tell me how to do this correctly?