调整文本框宽度的大小
我要求根据文本框的最大长度调整文本框宽度。即我正在使用特定的Maxlength值动态添加文本框控件。例如,如果最大长度为4,那么文本框的宽度应该是
,它只能容纳4个字符。
I have a requirement of Resizing the Textbox width based on the maxlength of the textbox. i.e. I am adding textbox control dynamically with specific Maxlength value. For example, if the max length is 4 then the width of the textbox should be such that it can accommodate only 4 characters.
请提示,如何实现这一目标silverlight。
Please suggest, how this can be achieved with silverlight.
谢谢你,
Raj
最简单的方法是手动确定前面使用的字体系列和大小的单个字符的近似宽度,只需设置Width属性即可到MaxLenght *这个静态/恒定宽度。
The easiest way to do this is probably to manually determine the approximate width of a single character for the font family and size you are using up front and simply set the Width property to MaxLenght * this static/constant width.
或者你可以看看以下方法:
Alternatively you could take a look at the following approach:
如何限制MaxLength TextBox?:
http://stackoverflow.com / questions / 4334792 / wpf-how-to-restrict-maxlength-of-textbox
希望有所帮助。
请记住通过将有用的帖子标记为答案来关闭您的主题d如果你有新问题,那么就开始一个新的主题。请不要在同一个帖子中提出几个问题。
Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.