How do I programmatically add text with line breaks to a textblock?
If I insert text like this:
helpBlock.Text = "Here is some text. <LineBreak/> Here is <LineBreak/> some <LineBreak/> more.";
Then the linebreaks get interpreted as part of the string literal. I want it to be more like what would happen if I had it in the XAML.
I can't seem to do it the WPF way either:
helpBlock.Inlines.Add("Here is some content.");
Since the Add() method wants to accept objects of type "inline".
I can't create an Inline object and pass it as a parameter because it is "inaccessible due to its protection level:
helpBlock.Inlines.Add(new Windows.UI.Xaml.Documents.Inline("More text"));
I don't see a way to programmatically add runs.
I can find a ton of WPF examples of this, but nothing for WinRT.
I've also turned up a lot of XAML examples, but nothing from C#.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…