The following forum(s) are migrating to a new home on Microsoft Q&A (Preview): Developing Universal Windows apps!

Ask new questions on Microsoft Q&A (Preview).
Interact with existing posts until December 13, 2019, after which content will be closed to all new and existing posts.

Learn More

 none
[UWP][VB][XAML]Adding/Editing TextBlock Inlines/Runs in Codebehind RRS feed

  • Question

  • As we all know, TextBlock has an Inlines property that contains Runs. This is not hard to edit in static XAML code, but how can I add or edit these in my codebehind? Intellisense doesn't even show an Inlines property, so I am not sure what to do. Any ideas? Thanks.

    Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/

    Monday, July 15, 2019 6:59 PM

Answers

  • Hi,

    So you want to add things to the Inline property of the TextBlock. You could try to add runs or other things to the TextBlock.Inlines like this:

                Run run = new Run();
                run.Text = "This is some text.";
    
                Span span = new Span();
    
                Italic Italic = new Italic();
    
                MyText.Inlines.Add(Italic);
                MyText.Inlines.Add(span);
                MyText.Inlines.Add(run);
    For more information, please refer this: Inline Class

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, July 16, 2019 2:21 AM
    Moderator