简体   繁体   English

我可以在控件中容纳多少个字符,WP7 Silverlight

[英]How many characters can I fit in a control, WP7 Silverlight

I want to take a dynamic string of text, and break it up so that it will fit in one or more textboxes or textblocks.我想获取一个动态的文本字符串,并将其分解,以便它适合一个或多个文本框或文本块。 Preferably textboxes.最好是文本框。 So let's say I get a string of text thats 132 characters long, but I can only display 40 characters in the textbox before it goes out of view.因此,假设我得到一个 132 个字符长的文本字符串,但在它消失之前我只能在文本框中显示 40 个字符。 So, I want to break up the text into 4 textboxes.所以,我想把文本分成 4 个文本框。 I want to find out programatically how many characters can be displayed.我想以编程方式找出可以显示多少个字符。

I tried ActualWidth, but get 0.0.我试过 ActualWidth,但得到 0.0。

There isn't a way to measure text on the phone.没有办法测量手机上的文本。 If you were only ever going to use a fixed text size you could measure all the characters in advance and calculate accordingly.如果您只打算使用固定的文本大小,您可以提前测量所有字符并进行相应计算。

However, you may find it easier to use the same method as in http://nerdplusart.com/texttrimming-textblock-for-silverlight to override MeasureOverride and trim the text until it fits.但是,您可能会发现使用与http://nerdplusart.com/texttrimming-textblock-for-silverlight相同的方法来覆盖 MeasureOverride 并修剪文本直到合适为止更容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Silverlight/Wp7 中单击时,如何从容器中弹出控件以使其全屏显示? - How can I pop a control out of it's container to make it full screen when clicked in Silverlight/Wp7? SilverLight / WP7:我可以在Silverlight和WP7中使用.net开源框架吗? - SilverLight / WP7: Can i use .net open source frameworks with silverlight & WP7? 如何用过渡替换Silverlight / WP7中的当前控件? - How to replace current control in Silverlight/WP7 with a transition? 如何在wp7上的Silverlight中始终将控件定位到屏幕上的固定位置? - How to always position a control to a fixed location on screen in silverlight on wp7? 如何在WP7上找到silverlight中控件的屏幕位置? - How do you find the screen position of a control in silverlight on WP7? 如何使用LocationCollection缩放以适应WP7 Bing Maps控件? - How to zoom to fit in WP7 Bing Maps control using LocationCollection? WP7 silverlight自定义控件使用弹出窗口 - WP7 silverlight custom control using popup 在WP7 silverlight应用程序中显示gif的控件 - Control for displaying gif in a WP7 silverlight application WP7/XNA/Silverlight:如何在绘制 TriangleStrip 后绘制 spriteBatch? - WP7/XNA/Silverlight: How can I draw a spriteBatch after I draw a TriangleStrip? 在WP7 + Silverlight中,如何更改列表框项目的视觉状态? - In WP7 + Silverlight how can I change the Visual State of an ListBox Item?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM