从代码后面滚动文本块中的文本

发布于 2024-08-23 07:40:43 字数 271 浏览 3 评论 0原文

我需要滚动文本块文本。例如,文本块包含 700 个单词。这些单词从代码后面填充到文本块中,因为根据某些“内容”,它可能是不同的 700 个单词。此表单上也有一个文本框。用户将文本块中的单词键入到文本框中。当他们打字时,我会跟踪他们所在的文本块中的哪个单词。但是,并非文本块中的所有单词都适合文本块查看区域,因此我需要从代码后面滚动文本块。我该怎么做呢?

我正在使用 silverlight 3。

谢谢 香农

抱歉..我没有意识到我没有在它自己的线程上问这个问题..我会再次发帖..

i need to scroll the textblock text. For example, the textblock contains 700 words. These words are populated to the textblock from code behind as it could be a different 700 words depending on some "stuff". There is a textbox on this form as well. The user types the words in the textblock into the textbox. As they type i keep track of which word from the textblock they are on. However, not all the words in the textblock will fit in the textblock viewing area, so i need to scroll the textblock from code behind. How do i go about doing this.

I"m using silverlight 3.

Thanks
shannon

sorry.. i didn't realize i didn't ask the question on it's own thread.. I'll post again..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

极致的悲 2024-08-30 07:40:43

首先,您需要将 TextBlock 包装在 ScrollViewer 控件中。此时,您可以在后面的代码中设置 ScrollViewer 的垂直和水平偏移,如下所示。请注意,这假定 ScrollViewer 控件名为 ScrollViewer1。

    Private Sub ScrollViewer1_MouseWheel(ByVal sender As Object, By Val e as System.Windows.Input.MouseWheelEventArgs)
        Me.ScrollViewer1.VerticalOffset = Me.ScrollViewer1.VerticalOffset + e.Delta
    End Sub

First you'll want to wrap your TextBlock in a ScrollViewer control. At that point, you can set the vertical and horizontal offsets of the ScrollViewer in the code behind like this. Note this assumes a ScrollViewer control named ScrollViewer1.

    Private Sub ScrollViewer1_MouseWheel(ByVal sender As Object, By Val e as System.Windows.Input.MouseWheelEventArgs)
        Me.ScrollViewer1.VerticalOffset = Me.ScrollViewer1.VerticalOffset + e.Delta
    End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文