Click here to Skip to main content
15,904,156 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a TextBox with a custom font (Matrix Book Regular), and the textbox max width is 285, I want the Text to auto scale x axis if the text width is larger then its width (Not to resize just to auto scale the X axis without changing the width of the text box) How to do that ?
Posted

1 solution

Welcome to WPF! You can graphically scale absolutely anything with the class System.Windows.Controls.Viewbox:
http://msdn.microsoft.com/en-us/library/system.windows.controls.viewbox.aspx[^].

—SA
 
Share this answer
 
Comments
Boudi AlSayed 28-Feb-13 20:27pm    
I already can scale TextBox without any other class (I have visual studio 2012 ultimate) but I don't know how to get the text width and to calculate it to scale it to specific width.
Sergey Alexandrovich Kryukov 28-Feb-13 20:50pm    
That's not it. ViewBox can scale it as if it was a bitmap...
—SA
Boudi AlSayed 28-Feb-13 20:52pm    
Ok, I know but how to get the text width of a text box?
Sergey Alexandrovich Kryukov 28-Feb-13 21:20pm    
Oh, there is no need to get its width. The situation is the opposite: the text box will be stretched to the width you define by the size iv the view box.

This is the amazing effect, by the way. What is the text? this is a vector graphics, with all vector elements (like curves, Besier of whatever) of each character, every such element will be scaled/translated accordingly. Just try it; and you will see...
—SA
Boudi AlSayed 28-Feb-13 21:44pm    
I'm trying to vote but I have some problems confirming my email, it says that it has been confirmed but can't vote :/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900