WPF equivalent to TextRenderer

前端 未结 2 1407
猫巷女王i
猫巷女王i 2020-11-28 09:51

I have used TextRenderer to Measure the length of a string and therefore size a control appropriately. Is there an equivalent in WPF or can I simply use T

2条回答
  •  我在风中等你
    2020-11-28 10:35

    Take a look at the FormattedText class

    If you need more granular control, then you'd need to descend to the GlyphTypeface type's AdvanceWidths member. Found a similar discussion here with a code snippet that looks like it might work.

    Update: Looks like this may be a duplicate of Measuring text in WPF .. OP please confirm.

提交回复
热议问题