Silverlight TreeView 禁用水平拉伸
我有一个 TreeView,我试图将其限制在其父级的尺寸内。我正在使用 SL4 TextTrimming 来修剪模板中显示的 TextBlock,但是我没有看到 TreeView 的宽度绑定到父级的宽度,因此包含长文本的 TextBlock 会超出 TreeView 的宽度。
我尝试禁用水平滚动条,将宽度绑定到父级,并摆弄 HorizontalAlignment 和 HorizontalContentAlignment,但我没有任何运气。任何意见都将受到高度赞赏。
I have a TreeView and I'm attempting to confine it to the dimensions of its parent. I'm using SL4 TextTrimming to trim the TextBlock that displays in the template however I'm not seeing the width of the TreeView bound to that of the parent so the TextBlocks containing long text push out the width of the TreeView.
I've tried disabling the horizontal scroll bar, binding the Width to the parent, and fiddling with the HorizontalAlignment as well as HorizontalContentAlignment but I'm not having any luck. Any input is greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
禁用水平滚动条不起作用的原因是在默认的 TreeView 样式中,滚动视图的 HorizontalScrollBarVisibility 设置为 Auto。您可以做的是创建自己的样式并将其 TemplateBinding 到父级。
应用此样式后,您应该有一个禁用水平滚动条的树视图。然后,您需要设置文本块的最大宽度以允许显示省略号。
如果这有帮助,请告诉我。 :)
the reason that disabling the horizontal scrollbar doesn't work is because in the default TreeView style, the scrollviwer's HorizontalScrollBarVisibility is set to Auto. What you can do is to create your own style and make it TemplateBinding to the parent.
After applying this style you should have a horizontal scrollbar disabled treeview. Then you need to set the max width of your textblock to allow the ellipsis to show.
Please let me know if this helps. :)