Tech Off Thread

6 posts

TextBlock wrapping of text in Silverlight XAML file.

Back to Forum: Tech Off
  • User profile image
    complete

    TextBlock wrapping of text in Silverlight XAML file.

    I have a wierd and annoying problem.  I have a textblock that is inside a stackpanel that is Oriented horizontal.  It would be nice if I could have the textblock appear in multiple lines nicely wrapped.  How could I do that?

  • User profile image
    bitdisaster

    Just set the TextWrapping property to "Wrap".

    <StackPanel x:Name="LayoutRoot" Background="White">           

    <TextBlock Text="Hello World, here is a very long text that will wrap." TextWrapping="Wrap" />   

    </StackPanel>

  • User profile image
    spivonious

    You might need to set a width for the TextBlock to get it to wrap properly. A horizontal StackPanel has an infinite maximum width.

  • User profile image
    bitdisaster

    @spivonious: that was what i thought too but it works without setting a width

  • User profile image
    figuerres

    ,section31 wrote

    @spivonious: that was what i thought too but it works without setting a width

    it will depend on how the surounding markup is done, if the textblock is in a more complex layout different things can happen....  also if this is in browser the html tags can make the container size have an effect on it.

  • User profile image
    figuerres

    C9 took a dump on me ....

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.