如何在 Silverlight 4 中设置 RichTextBox 以适应其父级高度并在调整大小时保持其不变?
我很难弄清楚这一点。这就是我需要的:
<StackPanel x:Name="container" VerticalAlignment="Stretch">
<RichTextBox Height="???" />
</StackPanel>
基本上我知道我可以做的是将 RichTextBox Height 绑定到它的父级高度( Height="{Binding ElementName=container, Path=ActualHeight}"
不幸的是,这仅适用于加载,因为看起来 ActualHeight 和 ActualWidth 不会通知更改,
那么 Silverlight 4 中告诉 RichTextBox 或 TextBlock 的最佳方法是什么。 >,没关系,填充它的父高度,并在内容高度较大时保持滚动条是绑定一些调整大小事件并显式保持高度的唯一方法吗?有人有这个吗?还有问题吗?
非常感谢任何资源或信息!
I am having hard times figuring this out. Here is what I need:
<StackPanel x:Name="container" VerticalAlignment="Stretch">
<RichTextBox Height="???" />
</StackPanel>
Basically what I know I can do is to bind RichTextBox Height to it's parent's height ( Height="{Binding ElementName=container, Path=ActualHeight}"
. Unfortunately this only works on load, because as it seems ActualHeight and ActualWidth don't notify for changes.
So what is the best way in Silverlight 4 to tell RichTextBox or TextBlock, it doesn't matter, to fill it's parent height, and maintain scrollbar if it's content height is bigger. Is the only way to bind some Resize events and maintain the height explicitly? That seems really ugly to me? Have anybody had this problem as well?
Any resources or information is highly appreciated! Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Ivan,
解决此问题的最佳方法是使用 Grid 作为 RickTextBox 的父级,而不是 StackPanel。默认情况下,网格将“拉伸”其内容以占据所有可用空间。 StackPanel 只会在一维上拉伸其内容。
例如,将以下 XAML 粘贴到我的 XamlViewer 中以查看差异:
祝你好运,
Jim McCurdy,Face to Face Software 和 YinYangMoney
Ivan,
The best way to solve this is to use a Grid as the parent for the RickTextBox, instead of a StackPanel. By default, a Grid will "Strectch" its content to take up all of the available space. A StackPanel will only Stretch its content in one diminsion.
As an example, paste the following XAML into my XamlViewer to see the difference:
Good luck,
Jim McCurdy, Face to Face Software and YinYangMoney