How to calculate the correct height for an auto-expanding textbox in Silverlight?
- by JacobE
In my Silverlight app I want a multi-line text box to expand every time the user hits Enter.
The difficult part is how to calculate the correct height based on the number of text lines.
I have tried the following but the textbox becomes too small:
box.Height = box.FontSize*lineCount + box.Padding.Top + box.Padding.Bottom + box.BorderThickness.Top + box.BorderThickness.Bottom;
What am I missing here? Or maybe it can be done automatically somehow?
Thanks,
Jacob
Edit: I suspect the problem to be in the FontSize property (does it use another size unit?)