0
votes

So say I have a textblock with a fontsize 32. The value of the text property is a variable amount of characters. If the text at a fontsize of 32 is cut off, how could i down scale the fontsize until the total width of the textblock is equal to the page width?

-I'd post a screenshot but not enough rep :/

1
You might have to come up with a logic of your own. The Textbox's width to readable fontsize ratio could be a metric to start with.. The you could update the Fontsize on the TextChanged event. But changing FontSizes sounds to me a bad UX..bit
what would you suggest?shady

1 Answers

1
votes

The best solution is insert the TextBlock inside a fix width ViewBox:

 <Viewbox Width="300" StretchDirection="Both" >
    <TextBlock x:Name="testblock" Foreground="Magenta" FontSize="24" Text="This is a test"/>
    </Viewbox>

And that will make the job without any effort. Change the parameters depending you need, and you can insert the textblock inside a border,etc.