Reputation: 7568
I have a TextBlock
which I want to be as big as possible without being multiple lines. I need to check to see if it flows onto the next line so that I can reduce the size of the text. I cannot set the max lines to 1, because then it will just cut off my text. How Can i see if there are multiple lines being used in my TextBlock
?
One way I was thinking of, but could not figure out, is something like:
if(TextBlock.Text.Width > TextBlock.Width)
or
if(TextBlock.Height > TextBlock.Text.Height)
But those don't seem doable from what I have seen.
Upvotes: 0
Views: 1026
Reputation: 12465
I agree with the comment by bit, but if you wish to do this, you can use a ViewBox control and place the TextBlock inside of it.
<Viewbox>
<TextBlock Text="Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut l"/>
</Viewbox>
Upvotes: 1