TextBlock without space

Hi,

Is it possible to have a TextBlock without the space arround the text (the space from the LineHeight etc.) What I am interested in is to display a text on one line and the bounds to exactly contain the content text.

Thank you,
Valentin




Answer this question

TextBlock without space

  • naru

    Hi,

    I need a control in which the text just "fits". TextBlock contains space for
    descenders, ascenders etc., but I would need something that changes its height according to the content text e.g. if there are no characters with descenders in the text, the height will be measured from the baseline.
    I think I would need to implement a custom control and use
    FormattedText and its Extent property.

    Thank you for your help,
    Valentin


  • Treval_Lightner

    Valentin,

    Correct, in this case you're probably best off implementing your own custom layout.

    Filipe  


  • G1

    Valentin,

    Does setting the LineHeight to be equal to the FontSize do what you expect

    If not, could you give more details around your request. Do you want a rectangle that includes descenders (i.e. the lower portion of a lowercase g) One that includes swashes (OpenType feature for decoration that draws strokes outside the bounds).

    Thanks.
    --
    Filipe Fortes
    http://fortes.com/work


  • TextBlock without space