locked
Indenting Multiple Lines in a TextBlock

    Question

  • I want to render the text of a TextBlock inside a boundary. What I basically need to do is indent the first x lines (not just the first 1 line) so that there is a blank rectangular area in the upper left. Is there a way to do this? Thanks.

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

    Tuesday, March 04, 2014 12:17 AM

All replies

  • Hi,

    You can add a run with transparent foreground to your TextBlock,see some codes below:

    <TextBlock Margin="8" HorizontalAlignment="Left" Width="300" Height="200" >                
                   <Run Foreground="Transparent"> text</Run>
                    line1
                 <LineBreak/>
                 <Run Foreground="Transparent"> text</Run>
                    line2
                 <LineBreak/>
                 <Run Foreground="Transparent"> text</Run>
                    line3
                    
            </TextBlock>
    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, March 04, 2014 2:06 AM
  • I was probably slightly unclear in what I wanted. My text (the Text property) is a String that does not have any linebreaks in it, so they must be determined dynamically by the TextBlock. I basically want to end up with something like this:

              This is where I will be
              putting my text, which
    does not have any linebreaks
    in it and must be determined
    dynamically by the app.

    Any ideas? Thanks.


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

    Tuesday, March 04, 2014 2:42 AM