Silverlight TextBlock 可以容纳多少个字符?
我正在尝试将最终用户许可协议(EULA)放入 WP7 silverlight 文本块控件中。但是,它不断截断我的文本。为什么会发生这种情况? WP7 silverlight 文本块可以容纳的文本大小或字符数是否有限制?
下面是我在 xaml 方面所做的示例(xaml 周围的其余部分是自动生成的默认值)。
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<ScrollViewer>
<TextBlock x:Name="tbMsg" TextWrapping="Wrap"/>
</ScrollViewer>
</Grid>
我也尝试过使用文本框,但现在,我什至无法在文本框中滚动。我也已明确将 VerticalScrollBarVisibility 设置为 Visible,但我仍然无法向下滚动 TextBox。事实上,我什至没有看到垂直滚动条。我不知道这个观察是否是因为我仍在通过模拟器查看用户界面。
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<TextBox x:Name="tbMsg" TextWrapping="Wrap" VerticalScrollBarVisibility="Visible"/>
</Grid>
i am trying to put a end-user license agreement (EULA) into a WP7 silverlight textblock control. however, it keeps truncating my text. why is this happening? is there a limit on the text size or number of characters a WP7 silverlight textblock can hold?
below is an example of what i've done in terms of xaml (the rest of the xaml surrounding is the default that is auto-generated).
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<ScrollViewer>
<TextBlock x:Name="tbMsg" TextWrapping="Wrap"/>
</ScrollViewer>
</Grid>
i've also tried using a TextBox, but now, i can't even scroll within the TextBox. i've explicitly set the VerticalScrollBarVisibility to Visible too, but i still can't scroll down the TextBox. in fact, i don't even see the vertical scroll bar. i don't know if this observation is because i'm still viewing the UI via the emulator.
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<TextBox x:Name="tbMsg" TextWrapping="Wrap" VerticalScrollBarVisibility="Visible"/>
</Grid>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
UIElement
在任一方向(高度或宽度)上都不能大于 2048 像素。任何超出此区域显示的内容都不会显示。 不过,在可视化树中保留了该内容所在的空间。解决此问题的方法是使用多个元素来显示大量文本。
更新
我已经编写了自己的解析器来动态显示此类内容。理想情况下,尽管您不会在运行时处理大块文本。当文本包含链接(指向其他页面、网络内容或电子邮件启动器)时,情况可能会更加复杂。
当想要显示 EULA 或任何大段文本时,您不会想让用户轻松阅读和导航。毕竟,您要包含希望用户阅读的文本。
如果您在设计时有文本,您应该抓住机会确保其布局正确,并且为不同部分使用单独的 TextBlock,并适当地设置标题和子标题的样式可以帮助您做到这一点。
No
UIElement
can be larger than 2048 pixels in either direction (height or width). Any content which would be displayed beyond this area isn't displayed. Space for where this content would be is reserved within the visual tree though.The work around for this is to use multiple elements to display large amounts of text.
Update
I've written my own parsers for dynaically displaying content of this sort. Ideally though you won't be working with large blocks of text at runtime though. This can be further complicated when the text contains links (to other pages, web content or email launchers).
When wanting to display EULAs or any large piece of text, you won't want to make it easy for the user to read and navigate. Afterall you are including the text as you want the user to read it.
If you have the text at design time you should take the opportunity to ensure that it is laid out appropriately and using separate TextBlocks for different sections and styling headings and sub-headings appropriately can help you do this.
这可能有几个原因 - 您的文本块的高度可能受到另一个控件的限制,您应用于文本的样式可能会导致它......
您可以发布您的源代码吗?
It could be several things - the height of your textblock may be being constrained by another control, a style you have applied to the text may be causing it...
Can you post your source?
我想与你分享这段代码。它创建许多 TextBlock 并作为子项添加到 Stackpanel。您可以在 Scroll 查看器中创建 Stackpanel,因为 Scrollvewers 只能直接获取单个子元素。
I want to share with you this code. It creates a number of TextBlocks and add as children to Stackpanel. You can create a Stackpanel inside your Scroll viewer since Scrollvewers can only take a single child element directly.