How to prevent packaging in WPF FlowDocument in C # code?

Studies have shown that this is a way to prevent the completion of, say, a paragraph:

<Paragraph> <TextBlock TextWrapping="NoWrap">unwrapping text</TextBlock> </Paragraph> 

How can I get behavior in c # code?

 new Paragraph(new TextBlock() { Text = "unwrapping text", TextWrapping = TextWrapping.NoWrap }); 

The output cannot convert from 'System.Windows.Controls.TextBlock' to 'System.Windows.Documents.Inline' because the Paragraph constructor expects Inline.

I cannot find a way to convert TextBlock to Inline to make Paragraph happy. If it works in XAML, there must be a converter somewhere, right? How do I find this?

I understand that the point of FlowDocument is that everything be moved and resized, etc. I am writing some simple reports, just some System.Windows.Documents.Table data, and unfortunately the first column that wraps, the one that contains dates, so

 2013-04-24 

becomes

 2013-04- 24 

So far I have used Run , and although they have some TextBlock properties, they are not TextTrimming TextWrapping or TextTrimming .

+4
source share
1 answer

If you want to add a TextBlock to inline strings, the constructor will not do it for you. I think it would be easiest to write:

 var p = new Paragraph(); p.Inlines.Add(new TextBlock() { Text = "unwrapping text", TextWrapping = TextWrapping.NoWrap }); 
+4
source

All Articles