locked
how to make an autosize font size in a textblock ? RRS feed

  • Question

  • hi there, i've a textblock control, and i want to fix its size ( hight and width) but also i want to make the size of the font changes automatically according to the length of the text , so that the font size will be as large as possible to show all the text ?
    Friday, February 19, 2010 9:50 AM

Answers

All replies

  • Howdy,

    Stick it inside a Viewbox and that will autoscale its children, which in this case is the text.

    Cheers

    Expression MVP

    my blog : http://x-coders.com/blogs/sneaky/default.aspx

    Friday, February 19, 2010 11:07 AM
    Moderator
  • Howdy,

    Stick it inside a Viewbox and that will autoscale its children, which in this case is the text.

    Cheers

    Expression MVP

     

    my blog : http://x-coders.com/blogs/sneaky/default.aspxthank for replaying,



    i've put my textblock inside a view box, ok ?
    now if i change the text inside the textblock to be a long sentence, it will not appeaer correctly, only the first few words will appear and the other words will be hidden .

    i will repeat my question again in another words :
    lets say i've textblock with 40pixels width and 320 pixels hight , this size is fixed, and the font size is 18px.

    i will change the content of the textblock in the run time, so if we have large sentence like " this is a sample sentence in a textblock made using microsof expression blend" it will not be shown, some words will be missing, so it should change the font size automatically to some smaller font size, 11 for example.

    the way of using the view box will make the text appears as a picture streching and contracting but doesn't change the font size !
    • Edited by AL Nabhani Friday, February 19, 2010 2:20 PM add some comments
    Friday, February 19, 2010 2:12 PM
  • thanks, it works fine now !
    Friday, February 19, 2010 3:12 PM