Search code examples
windows-8winrt-xamltextblock

Should I remove the "Run" from my TextBlocks?


I've got some TextBlocks that look like so:

        <TextBlock>
                <Run Text="Prev"/>
        </TextBlock>

However, when I created them they didn't have the "Run" jazz. Was this something added by a tool, and if so, why? Should I remove it/what is Run's raison detre?


Solution

  • The Textbox described in your question could also be achieved by using

    <TextBlock Text="Prev"/>
    

    Run is just another way of setting the text of a textbox. Is use may become more apparent when you want to format certain parts of text in a textbox e.g.

    <TextBlock>
        <Run Text="Number: " FontStyle="Bold" />
        <Run Text="1" />
    </TextBlock>
    

    Which might display something like

    Number: 1