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.
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.