locked
Letter wrapping in TextBlock

    Question

  • Is there some relatively simple way of doing letter wrap in TextBlocks, or are we really forced to use only word wrapping (or no wrapping)? Why? It is not suitable in some cases and letter wrapping would be probably very easy to add to this object, as it is already doing this for texts without spaces.

    Thanks.


    • Edited by Michal Pilar Wednesday, December 19, 2012 12:54 PM
    Wednesday, December 19, 2012 12:53 PM

All replies

  • I have same need.
    Thursday, December 20, 2012 12:48 AM
  • Hi,

    I was not clear your question, here is warp property in TextBlock
    TextWrapping="Wrap"

    What's effect do you want in the TextBlock.

    Best regards,
    Jesse


    Jesse Jiang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, December 21, 2012 5:38 AM
  • Hi,

    I was not clear your question, here is warp property in TextBlock
    TextWrapping="Wrap"

    What's effect do you want in the TextBlock.

    Best regards,
    Jesse

    This will do word wrap, i.e. text "Aaaaaaaa Bbbbbbbbbbbbbbbb CC" it will divide e.g. this way:

    "Aaaaaaaa
    Bbbbbbbbbbbbbbbb
    CC"

    But I would like to divide it after the last letter, that fits, not last word, i.e.

    "Aaaaaaaa Bbbbbbbb
    bbbbbbbb CC"

    Friday, December 21, 2012 3:27 PM
  • Hi,

    First, we can change the width of TextBlock so that we can get the result like:

    Aaaaaaaa
    Bbbbbbbbbbbbbbbb  CC

    The Bbbbbbbbbbbbbbbb is a word, there is no directly to separate Bbbbbbb into two lines.

    But we can put a blank like "Bbbbb bbbbb", so that we can get the result.

    Best regards,
    Jesse


    Jesse Jiang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Proposed as answer by Jesse Jiang Wednesday, December 26, 2012 2:24 AM
    Monday, December 24, 2012 3:27 AM
  • So we are really forced to use word wrap, this is what I am saying in the first post.  But why? It is not so easy to programmatically calculate, where to insert space, because the text is unknown in advance (e.g. some user path) and contains characters of different sizes. The point is, why we are forced to make it all manually, if TextBlock knows how to split it (because of text without spaces) and only does not allow developer to use it... Silly.
    Wednesday, December 26, 2012 4:27 PM
  • Today I found there is one more property came out, which is not documented, can you try <TextBlock Text="aaaaaaaaaaaaaa" TextTrimming="WordEllipsis"/>?
    Thursday, January 3, 2013 8:46 PM
  • TextTrimming is documented (http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.textblock.texttrimming.aspx), it works as described, i.e. does something different.
    • Edited by Michal Pilar Thursday, January 3, 2013 9:15 PM
    • Proposed as answer by Jesse Jiang Monday, January 7, 2013 5:59 AM
    • Unproposed as answer by Michal Pilar Monday, January 7, 2013 6:29 AM
    Thursday, January 3, 2013 9:14 PM