I have this XAML:
<TextBlock TextWrapping="Wrap" Foreground="Green"
Text="This is some Green text up front. ">
<TextBlock Foreground="Blue">
This is some Blue text.
</TextBlock>
This is some Green text following the Blue text.
<Hyperlink>
<TextBlock Text="And finally, this is a Hyperlink." TextWrapping="Wrap"/>
</Hyperlink>
</TextBlock>
And I'd like to know how to replicate it procedurally in C#.
I know how to create TextBlocks in C# with something like:
TextBlock tb = new TextBlock();
tb.Text="Some text"
And I can put multiple textblocks together in a panel within C#. But I don't see how you go about putting TextBlocks into other TextBlocks, and TextBlocks into hyperlinks into Textblocks.
Are some container objects and extra TextBlock objects being created automatically, somehow? Or does the TextBlock have some methods/properties that allow it to contain the other items?
Other related questions:
1. What's the best way to add something like a Click() event to the Hyperlink?
2. Is there a way to get the blue text to wrap more cleanly? In the above XAML, as soon as the rightmost word would need to wrap, the entire block of blue text is wrapped instead.
Thanks for any illumination you can provide.