Silverlight 4 - 鼠标滚轮在包含的 RichTextBox 上方时停止滚动 ScrollViewer
我有一个 Silverlight 4 浏览器外应用程序,其中有一个 ScrollViewer,里面有几个 RichTextBox。 RichTextBox 仅用于显示文本,从不编辑,也从不滚动。
但是,当鼠标悬停在 RichTextBox 上时,鼠标滚轮事件似乎无法到达 ScrollViewer。有什么办法可以克服这个限制吗?
I have a Silverlight 4 out-of-browser application with a ScrollViewer that has several RichTextBoxes inside. The RichTextBoxes are only used for displaying text, and are never edited and never scroll.
However when the mouse is hovering over a RichTextBox the mousewheel event seems to not reach the ScrollViewer. Is there any way to overcome this limitation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只读 RichTextBox 不滚动的原因是 RichTextBox 的默认模板使用 ScrollViewer 而不是 ContentControl。因此,要解决这个问题,您需要为RichTextBox创建自己的模板。
我所做的是在 Blend 中创建 RichTextBox 模板的副本,并将其剥离以用于只读情况。这会删除大约 90% 的模板。保留以下样式/模板:
将此样式/模板用于只读 RichTextBox,您应该可以开始了。
祝你好运,
吉姆·麦柯迪
面对面软件和 YinYangMoney
The reason a readonly RichTextBox doesn't scroll is because the default template for RichTextBox uses a ScrollViewer instead of a ContentControl. So to solve the problem, you need to create your own template for RichTextBox.
What I did was to create a copy of the RichTextBox template in Blend, and strip it down for the readonly case. This removes about 90% of the template. The following style/template remains:
Use this style/template for your readonly RichTextBox'es, and you should be good to go.
Goood luck,
Jim McCurdy
Face to Face Software and YinYangMoney