WPF text Wrap vs WrapWithOverflow

前端 未结 3 1190
北海茫月
北海茫月 2020-12-04 17:30

What\'s the \"conceptual\" difference between TextWrapping=\"Wrap\" and TextWrapping=\"WrapWithOverflow\" (e.g. for a TextBox)? In the MSDN page ab

3条回答
  •  甜味超标
    2020-12-04 17:48

    Some examples:

    This is the original, unwrapped version:

    No wrapping


    This is NoWrap.

    NoWrap


    This is Wrap. The words Remove and Sample have been wrapped at the ve and le, respectively, even though there is no line break opportunity.

    Wrap


    This is WrapWithOverflow. The ve and le are not visible (they overflow the available block width) because there is no line break opportunity. The All, in both cases, has been wrapped because the space character is a line break opportunity.

    WrapWithOverflow


    Edit:

    As suggested in the comments, here's some examples of how Wrap treats spaces. When Width is 100, Wrap and WrapWithOverflow are identical. Wrap treats the space between wider and example as a line-break opportunity, so example is put on a new line to preserve the entire, continuous word.

    enter image description here

提交回复
热议问题