WPF: Get “wrapped” text out of a textbox

后端 未结 4 661
执笔经年
执笔经年 2021-01-18 18:46

Is there a way in WPF to get the text formatted as it display on the textbox when TextWrapping=\"Wrap\"?



        
4条回答
  •  情话喂你
    2021-01-18 19:07

    For that you have to write your own logic by making use of text measurement API.

    STEP 1: Bresk the textbox text in to words.

    STEP 2: Then measure each word width and combine them until the line width is less than textbox width.

    Refer this post which explains about text measurement process. (social.msdn.microsoft.com/forums/en-US/wpf/thread/…)

提交回复
热议问题