add new lines to the top in the textblock

If your TextBlock has a name and you modify it from code-behind…

<TextBlock x:Name="MyTextBlock"/>

You can use InsertBefore with FirstInline to add the inline as first element to Inlines.

MyTextBlock.Inlines.InsertBefore(MyTextBlock.Inlines.FirstInline, new Run("My text to add as first inline."));

If you want to put newlines in between the text that you add, use LineBreak.

MyTextBlock.Inlines.InsertBefore(MyTextBlock.Inlines.FirstInline, new LineBreak());

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top